Results 1 to 3 of 3

Thread: Creating Widgets

  1. #1
    Join Date
    Feb 2006
    Posts
    2
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Creating Widgets

    Hello,
    I've noticed that I my widgets will only get shown when I create them at the initialisation of the class(in the constructor, or functions that were (indirectly) called by the constructor. If they're created later, they are(for some strange reason) not shown.
    To show what I mean:
    Qt Code:
    1. class Myclass : public QWidget {
    2. Q_OBJECT
    3. public: Myclass(QWidget *parent=0, const char *name=0); QPushButton *but1, *but2;
    4. protected slots: void createbutton()
    5. };
    6.  
    7. Myclass::Myclass(QWidget *parent, const char *name) : public QWidget(parent, name) {
    8. but1 = new QPushButton("click to add button", this);
    9. connect(but1, SIGNAL(clicked()), this SLOT(createbutton()));
    10. }
    11. void Myclass::createbutton() {
    12. but2 = new QPushButton("but2", this); // Will not be shown
    13. }
    To copy to clipboard, switch view to plain text mode 
    I'm currently creating a dialog, using QPtrList, but I can't add widgets to QPtrList at initialization, because I get the information needed to create the widgets after i'm logged in, and that results in the widgets not being shown. However, when I add some widgets(just to test it) in the constructor, it does show them.
    My question is: Is there someway to add the widgets later and still show them(maybe by adding those widgets manually to a QObject list?)?
    Thanx in advance,
    Hylke

  2. #2
    Join Date
    Jan 2006
    Location
    Minsk, Brest, Belarus
    Posts
    54
    Thanks
    3
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Creating Widgets

    try show() function

  3. #3
    Join Date
    Feb 2006
    Posts
    2
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Creating Widgets

    Wow, thanks.
    I still can't believe that it could be solved so easily
    Hylke

Similar Threads

  1. creating widgets asynchronously
    By tampstaffs in forum Qt Programming
    Replies: 3
    Last Post: 23rd February 2009, 10:30
  2. Upper limit on number of widgets?
    By jdiewald in forum Qt Programming
    Replies: 1
    Last Post: 29th September 2008, 23:00
  3. Creating And Destoying composite Widgets
    By morraine in forum Newbie
    Replies: 3
    Last Post: 31st August 2008, 16:57
  4. Replies: 2
    Last Post: 16th May 2008, 14:39
  5. Performance in hiding/showing widgets
    By Paalrammer in forum Newbie
    Replies: 12
    Last Post: 14th February 2007, 18:57

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.