[Qt-interest] Adding widget to QGraphicsView

Yuvaraj R yuvaraj at ongobiz.com
Wed Jul 22 16:32:57 CEST 2009


I declared the the Qlabel ,QlineEdit as private in Class..

if use the label apart from the constrcutor application crashing..

*sample code.*
ui->setupUi(this);

this->setWindowFlags(Qt::WindowSystemMenuHint);

QGraphicsScene *scene= new QGraphicsScene();

QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget;

QLabel *label = new QLabel();

label->setText("Username");

QFont font;

font.setPointSize(9);

label->setFont(font);

proxy = scene->addWidget(label);

proxy->setPos(50,130);

QLineEdit *line = new QLineEdit();

proxy = scene->addWidget(line);

proxy->setPos(120,130);

proxy->setMaximumWidth(120);

ui->graphicsView->setScene(scene);

QLabel *label1 = new QLabel();

label1->setText("PassWord");

label1->setFont(font);

proxy = scene->addWidget(label1);

proxy->setPos(50,170);

QLineEdit *line1 = new QLineEdit();

proxy = scene->addWidget(line1);

proxy->setPos(120,170);

proxy->setMaximumWidth(120);

QPushButton *button = new QPushButton();

button->setText("Login");

button->setMaximumWidth(60);

proxy = scene->addWidget(button);

proxy->setPos( 150, 220);

QLabel *label3 = new QLabel();

label3->setText("Welcome to MaxxTel");

font.Bold;

font.setPointSize(13);

label3->setFont(font);

proxy = scene->addWidget(label3);

proxy->setPos(100,50);

ui->graphicsView->setScene(scene);

QObject::connect(button,SIGNAL(clicked()),this,SLOT(show_message1()));

 }

Widget::~Widget()

{

delete ui;

}

void Widget::show_message1()

{

QMessageBox::information(0,"",QString("yuvaraj"));

label->hide();

label1->hide();

QMessageBox::information(0,"2",QString("yuvaraj"));

label3->hide();

line->hide();

line1->hide();

button->hide();

QMovie *movie = new QMovie("../Icons/loader.gif");

QLabel *label4 = new QLabel;

label4->setMovie(movie);

QMessageBox::information(0,"3",QString("yuvaraj"));

movie->start();

QMessageBox::information(0,"1",QString("yuvaraj"));

label4->setGeometry(50,50,200,200);

proxy = scene->addWidget(label4);

ui->graphicsView->setScene(scene);

QMessageBox::information(0,"5",QString("yuvaraj"));

}

i used to put current class as parent of label ,but align ment was not
proper and when i am clicking the button..nothing happened..


Thanks

Yuvaraj R

On Wed, Jul 22, 2009 at 7:53 PM, Srdjan Todorovic <
todorovic.s at googlemail.com> wrote:

> Hi,
>
> On 22/07/2009, John McClurkin <jwm at nei.nih.gov> wrote:
> > The compiler went to Qlineedit.h 268? I assume you mean that the
> > debugger went to qlineedit.h 268. If this is a stack trace, then this
> > line just the last entry of the trace. Since this is a Qt src file, I
> > double strongly that the error is here.
>
> The error is probably not there, but that's where it's manifested.
>
> eg.
>
>  char buf[4];
>  QWidget yay;
>
>  ::memset(&buff, 0, 60);
>
>  yay.show();  // bang!
>
> The debugger will probably catch yay's members as the cause of the
> crash (eg you set an internal pointer to NULL or some other invalid
> value).
> But it was actually the size param to memset() that is the error.
> (I'm sure you all know this ;) )
>
> > The error was triggered by your
> > code. You need to examine the stack trace to find the entries that
> > identify your code. That said, I would guess that, since the debugger
> > stops in qlineedit.h, you are using an invalid pointer to a QLineEdit
> > widget.
>
> Let me also add "use the debugger and get a stack trace".
>
> All you need to do is:
>  gdb ./myprogram
>  run
>  bt
>
> So simple, yet so important.
>
> Good luck,
> Srdjan
>  _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090722/9b896e06/attachment.html 


More information about the Qt-interest-old mailing list