PDA

View Full Version : How do I create an Object at runtime?



Cayan
28th June 2010, 02:47
I'm trying to develop an option where according to some options the Dialog gets resized and some new objects appear on screen. What I'm trying is:

label1 = new QLabel(this);
label1->setObjectName(QString::fromUtf8("label1"));
label1->setProperty("text", "Direction:");
label1->setProperty("geometry", QRect(10, 70, 43, 13));

This is from my last try, I've also attempted to do it with directly property changes, like: label1->setText("Direction:");
It does not return any error... it simple does nothing...
I don't wanna manage hidden objects for this, it is far better to make them dynamically but something is happening and I don't know what... :confused:

ChrisW67
28th June 2010, 03:39
You don't describe the problem but I think what you are expecting is that creating the QLabel automatically puts it on the screen. If that is the problem then you need to add the new QLabel to the appropriate layout before it will be on-screen (and show() it if need be).

Cayan
28th June 2010, 07:01
I can't believe the problem was a simple show() :mad:
Thanks a lot