Results 1 to 3 of 3

Thread: How do I create an Object at runtime?

  1. #1
    Join Date
    Apr 2009
    Posts
    10
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default How do I create an Object at runtime?

    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:
    Qt Code:
    1. label1 = new QLabel(this);
    2. label1->setObjectName(QString::fromUtf8("label1"));
    3. label1->setProperty("text", "Direction:");
    4. label1->setProperty("geometry", QRect(10, 70, 43, 13));
    To copy to clipboard, switch view to plain text mode 

    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...

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How do I create an Object at runtime?

    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).

  3. #3
    Join Date
    Apr 2009
    Posts
    10
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How do I create an Object at runtime?

    I can't believe the problem was a simple show()
    Thanks a lot

Similar Threads

  1. Replies: 1
    Last Post: 27th February 2010, 10:33
  2. Replies: 1
    Last Post: 1st February 2010, 15:13
  3. Eclipse debugging: Unable to create variable object
    By PUK_999 in forum Installation and Deployment
    Replies: 0
    Last Post: 20th August 2009, 21:42
  4. finding dynamically create object
    By abrou in forum Newbie
    Replies: 2
    Last Post: 5th March 2008, 21:17
  5. Can't create an object : initialisation problem ?
    By Nyphel in forum Qt Programming
    Replies: 5
    Last Post: 12th March 2007, 09:07

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.