Results 1 to 5 of 5

Thread: How to show and hide Button when i created.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2011
    Location
    Việt Nam
    Posts
    8
    Thanks
    3
    Qt products
    Qt3 Qt4 Qt/Embedded Qt Jambi PyQt3 PyQt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default How to show and hide Button when i created.

    - Create Layout:

    Qt Code:
    1. void Schedule::createLayout()
    2. {
    3. QVBoxLayout *mainLayout = new QVBoxLayout();
    4. QGridLayout *daysLayout = new QGridLayout();
    5. QWidget *viewport = new QWidget();
    6. mainLayout->addWidget(viewport);
    7.  
    8. Token *label = new Token(this);
    9. label->setAlignment(Qt::AlignLeft);
    10. QList<Token *> cwList;
    11. cwList.append(label);
    12. daysLayout->addWidget(label);
    13.  
    14.  
    15. for (int i = 0; i < 5; i++ )
    16. {
    17. Button *label = new Button(this);
    18. label->setAlignment(Qt::AlignLeft);
    19. label->setOptimumSize(299, 15);
    20. label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    21. SchedulesList.append(label);
    22. daysLayout->addWidget(label);
    23. }
    24.  
    25. daysLayout->setSpacing(1);
    26. daysLayout->setContentsMargins(0,0,0,0);
    27. daysLayout->setAlignment(Qt::AlignCenter);
    28. viewport->setLayout(daysLayout);
    29.  
    30. mainLayout->setSpacing(0);
    31. mainLayout->setContentsMargins(0,0,0,0);
    32. mainLayout->setAlignment(Qt::AlignCenter);
    33. setLayout(mainLayout);
    34. }
    To copy to clipboard, switch view to plain text mode 
    - i want update layout can show and hide button.
    i use:
    Qt Code:
    1. QLayoutItem *Item = NULL;
    2. for (int i = 0; i < 5; i++)
    3. {
    4. Item = daysLayout->itemAt(i);
    5. if (Item)
    6. {
    7. Item->widget()->hide();
    8. Item->widget()->adjustSize();
    9. Item->widget()->updateGeometry();
    10. }
    11. }
    12. daysLayout->update();
    To copy to clipboard, switch view to plain text mode 

    But i can't show them again.
    How to do this??
    Many thank!!!
    Last edited by high_flyer; 14th March 2011 at 10:29. Reason: code tags

Similar Threads

  1. Replies: 10
    Last Post: 20th April 2015, 22:24
  2. Hide/show the Cancel button in a QProgressDialog
    By Vankata in forum Qt Programming
    Replies: 9
    Last Post: 24th February 2011, 20:43
  3. how to show an app if it manually hide
    By jthacker in forum Qt Programming
    Replies: 1
    Last Post: 26th March 2010, 13:02
  4. Replies: 5
    Last Post: 21st November 2007, 09:51
  5. Show or hide a form
    By Gayathri in forum Newbie
    Replies: 11
    Last Post: 17th November 2006, 12:39

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
  •  
Qt is a trademark of The Qt Company.