hi, anyone know why the text on label doesn't appear?? thanks
Printable View
What is this->Mo ?
Is Mo shown ?
try calling show() at the end of the constructor.
mo is a Widget; the label is shown; the background color appear....i tried show() but don't change...
oh sorry, I thought the label was not appearing. My mistake.
You are not setting any text and therefore no text appears.
uncomment setText(s)
don't work.....I just tried
you should put ur labels in ctor or any other function called at startup.
Hi see that setText(s) in the constructor works! the problem was the presence the paintEvent(); I could put p.drawText inside paintEvent but this eat the setText of constructor; How can I avoid this? (I want set text on label to be s).thanks
Code:
setText(s); } myMainForm::myMainform() { lab1 = new myLabel ("Mod1", this->Mo,""); lab2 = new myLabel ("Mod2", this->Mo,""); } QPainter p; p.begin( this ); p.rotate(20.0); p.drawRect(35,5,70,70); //p.drawText(50,50, "????" Qt::AlignCenter ); p.end(); }
You must invoke the base class's implementation of the paintEvent() somewhere:Quote:
Originally Posted by mickey
Code:
p.rotate(20.0); p.drawRect(35,5,70,70); p.end(); }
thank for this;
but I need also rotate it;
so how to do this?
Code:
p.drawText(50,50, textLabel, Qt::AlignCenter ); mylabel.cpp(106): error C2664: 'void QPainter::drawText(int,int,const QString &,int,QPainter::TextDirection)' : cannot convert parameter 3 from 'QString *' to 'const QString &'
Could anyone help me (last message)? thanks
Which parameter of the QPainter::drawText() does this error message refer to?Quote:
Originally Posted by mickey
What type does it expect?
What is the type of variable you have used?