Results 1 to 4 of 4

Thread: Dynamically resizing in QT 3

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Posts
    75
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Dynamically resizing in QT 3

    I'm trying to do the examples in the QT 3 tutorial titled "C++ GUI Programming with Qt 3." Please note that I am trying to do the examples without QT Designer.

    In chapter 2 there is a more button which allows a user to extend an options menu. The button works, but when it is toggled off, the size of the dialog screen remains the same. Is there a way to have it dynamically shrink to its original size?

    Here is the constructor for my class, which inherits from QDialog:

    Qt Code:
    1. SortDialog::SortDialog(QWidget * parent, const char * name)
    2. : QDialog(parent, name)
    3. {
    4. setCaption("Sort");
    5.  
    6. pGroup = new QGroupBox( 2, Qt::Horizontal, "&Primary Key", this);
    7. pLabel1 = new QLabel("Column", pGroup);
    8. pCombo1 = new QComboBox(pGroup);
    9. pLabel2 = new QLabel("Order", pGroup);
    10. pCombo2 = new QComboBox(pGroup);
    11.  
    12. sGroup = new QGroupBox( 2, Qt::Horizontal, "&Secondary Key", this);
    13. sLabel1 = new QLabel("Column", sGroup);
    14. sCombo1 = new QComboBox(sGroup);
    15. sLabel2 = new QLabel("Order", sGroup);
    16. sCombo2 = new QComboBox(sGroup);
    17.  
    18. tGroup = new QGroupBox( 2, Qt::Horizontal, "&Tertiary Key", this);
    19. tLabel1 = new QLabel("Column", tGroup);
    20. tCombo1 = new QComboBox(tGroup);
    21. tLabel2 = new QLabel("Order", tGroup);
    22. tCombo2 = new QComboBox(tGroup);
    23.  
    24. okButton = new QPushButton("&Ok", this);
    25. cancelButton = new QPushButton("&Cancel", this);
    26. moreButton = new QPushButton("&More", this);
    27. moreButton->setToggleButton(TRUE);
    28.  
    29. connect(okButton, SIGNAL(clicked()),
    30. this, SLOT(accept()));
    31. connect(cancelButton, SIGNAL(clicked()),
    32. this, SLOT(reject()));
    33. connect(moreButton, SIGNAL(toggled(bool)),
    34. sGroup, SLOT(setShown(bool)));
    35. connect(moreButton, SIGNAL(toggled(bool)),
    36. tGroup, SLOT(setShown(bool)));
    37.  
    38. QVBoxLayout *vert1 = new QVBoxLayout;
    39. QVBoxLayout *vert2 = new QVBoxLayout;
    40. vert1->addWidget(pGroup);
    41. vert1->addStretch(1);
    42. vert1->addWidget(sGroup);
    43. vert1->addWidget(tGroup);
    44. vert2->addWidget(okButton);
    45. vert2->addWidget(cancelButton);
    46. vert2->addWidget(moreButton);
    47. vert2->addStretch(1);
    48.  
    49. QHBoxLayout *main = new QHBoxLayout(this);
    50. main->setMargin(10);
    51. main->setSpacing(10);
    52. main->addLayout(vert1);
    53. main->addLayout(vert2);
    54.  
    55. sGroup->hide();
    56. tGroup->hide();
    57. setColumnRange('A', 'Z');
    58.  
    59. }
    To copy to clipboard, switch view to plain text mode 

    I guess that I could create my own slot that uses the boolean value and resets the size of the QDialog if toggle is false. In that case what member function will let me resize QDialog?
    Last edited by kroenecker; 9th January 2006 at 18:36.

Similar Threads

  1. Problem on Resizing of QTableView colums ?
    By rajeshs in forum Qt Programming
    Replies: 2
    Last Post: 28th March 2008, 04:03
  2. Replies: 2
    Last Post: 14th August 2007, 15:16
  3. QMdiSubWindow resizing in 4.3
    By kalpa in forum Qt Programming
    Replies: 0
    Last Post: 4th June 2007, 13:39
  4. Dynamically adding tabs
    By larry104 in forum Qt Programming
    Replies: 7
    Last Post: 26th July 2006, 20:27
  5. Resizing the dialog box dynamically
    By vvbkumar in forum Newbie
    Replies: 5
    Last Post: 20th June 2006, 08:54

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.