[Qt-interest] A error about QLabel::setText(const QString &) ?
Guido Moonen
gmoonen at nr34.nl
Fri Feb 27 16:22:12 CET 2009
Hi Kermit,
It seems one of the label_xx pointers is still NULL, hence the this=0x0
in the QLabel::setText.
Have you initialized these labels?
otherwise try to protect the calls using
if (label_xx != NULL)
label_xx->setText(strxx);
With kind regards,
Guido Moonen
Kermit Mei wrote:
> Hello! In my widget I defined the following method, and all the label_** in
> it is the type of QLabel.
>
>
> void ResultWidget::setInfo(const QString &str11,const QString &str12,
> const QString &str21,const QString &str22,
> const QString &str31,const QString &str32) {
> label_11->setText(str11);
> label_12->setText(str12);
>
> label_21->setText(str21);
> label_22->setText(str22);
>
> label_31->setText(str31);
> label_32->setText(str32);
>
> }
>
> After make the project, everything goes well, but when I run it, the program
> broke down here. The gdb output is:
>
> Program received signal SIGSEGV, Segmentation fault.
> QLabel::setText (this=0x0, text=@0xbfc70874) at widgets/qlabel.h:155
> 155 widgets/qlabel.h: No such file or directory.
> in widgets/qlabel.h
>
>
> And the stack of the program are:
> (gdb) bt
> #0 QLabel::setText (this=0x0, text=@0xbfc70874) at widgets/qlabel.h:155
> #1 0xb7f28e7f in ResultWidget::setInfo (this=0x80c7368, str11=@0xbfc70874,
> str12=@0xbfc70870, str21=@0xbfc7086c, str22=@0xbfc70868,
> str31=@0xbfc70864, str32=@0xbfc70860)
> at /home/kermit/Project/QFreeRecite/src/gui/ResultWidget.cpp:20
> ... ...
>
> I don't know why this takes errors. All the arguments I put into the arglist
> is standard QString type.
>
> What may cause it?
>
> Thanks.
> Kermit Mei
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
More information about the Qt-interest-old
mailing list