Results 1 to 6 of 6

Thread: how to increase the size of the dialog box at run time?

  1. #1
    Join Date
    Oct 2011
    Posts
    160
    Thanks
    31
    Qt products
    Qt4
    Platforms
    Windows

    Default how to increase the size of the dialog box at run time?

    I'm calling a dialog at runtime, and adding content to that dialog(radio buttons),
    but size of the dialog fixed and does not display properly (looks very very small) when number of content increases....
    How can i get rid of this?
    The code i wrote as shown below...


    Qt Code:
    1. void Dialog::Display_header(QStringList headerList)
    2. {
    3. for(int i=0;i<headerList.count();i++)
    4. {
    5. QRadioButton *Rbutton= new QRadioButton();
    6. Rbutton->setText(headerList.at(i));
    7. ui->verticalLayout->addWidget(Rbutton);
    8.  
    9. }
    10. }
    To copy to clipboard, switch view to plain text mode 

  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 to increase the size of the dialog box at run time?


  3. #3
    Join Date
    Oct 2011
    Posts
    160
    Thanks
    31
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to increase the size of the dialog box at run time?

    Quote Originally Posted by ChrisW67 View Post
    Thank u chris.....but in my case the dialog may contain only one radio button or it can increase upto 30......depending on that the size of dialog must increase.....i tried vertical spacer, but that didnt help me...
    As number of radio button increases the font becomes small and dialog size also wont expand...

  4. #4
    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 to increase the size of the dialog box at run time?

    The key is the
    Qt Code:
    1. mainLayout->setSizeConstraint(QLayout::SetFixedSize);
    To copy to clipboard, switch view to plain text mode 
    line

  5. #5
    Join Date
    Oct 2011
    Posts
    160
    Thanks
    31
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to increase the size of the dialog box at run time?

    This is the code i wrote.....here contents adding properly....but dialog size not incrementing accordingly...please tell me what i'm missing here....


    Qt Code:
    1. void Dialog::Display_header(QStringList headerList)
    2. {
    3.  
    4. for(int i=0;i<headerList.count();i++)
    5. {
    6. QRadioButton *Rbutton= new QRadioButton();
    7.  
    8. Rbutton->setText(headerList.at(i));
    9. ui->verticalLayout->addWidget(Rbutton);
    10. ui->verticalLayout->setAlignment(Qt::AlignTop);
    11.  
    12. ui->verticalLayout->setSpacing(1);
    13. ui->verticalLayout->setStretch(1,1);
    14. }
    15. }
    To copy to clipboard, switch view to plain text mode 

  6. #6
    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 to increase the size of the dialog box at run time?

    See my previous post and the Extension Example. Seriously.

    Here is a potted example:
    Qt Code:
    1. #include <QtGui>
    2.  
    3. class MagicDialog: public QDialog {
    4. Q_OBJECT
    5. public:
    6. MagicDialog(QWidget *p = 0): QDialog(p) {
    7. QVBoxLayout *layout = new QVBoxLayout;
    8. layout->setSizeConstraint(QLayout::SetFixedSize); // <<<<< THIS
    9. setLayout(layout);
    10.  
    11. QPushButton *button = new QPushButton("Add one", this);
    12. connect(button, SIGNAL(clicked()), SLOT(addOne()));
    13. layout->addWidget(button);
    14.  
    15. button = new QPushButton("Remove one", this);
    16. connect(button, SIGNAL(clicked()), SLOT(removeOne()));
    17. layout->addWidget(button);
    18. }
    19. public slots:
    20. void addOne() {
    21. QRadioButton *rbutton = new QRadioButton(QString("Label %1").arg(rbuttons.size()), this);
    22. rbuttons.append(rbutton);
    23. layout()->addWidget(rbutton);
    24. }
    25. void removeOne() {
    26. if (rbuttons.size()) {
    27. QRadioButton *rbutton = rbuttons.takeLast();
    28. rbutton->deleteLater();
    29. }
    30. }
    31. private:
    32. QList<QRadioButton*> rbuttons;
    33. };
    34.  
    35. int main(int argc, char *argv[])
    36. {
    37. QApplication app(argc, argv);
    38.  
    39. MagicDialog d;
    40. d.show();
    41. return app.exec();
    42. }
    43. #include "main.moc"
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. increase the size of my plot
    By 21did21 in forum Qwt
    Replies: 4
    Last Post: 29th May 2011, 11:03
  2. Increase legend icon size?
    By torrentss in forum Qwt
    Replies: 2
    Last Post: 1st September 2010, 12:26
  3. Replies: 3
    Last Post: 4th September 2009, 12:49
  4. Increase the size of radio buttons
    By arunvv in forum Qt Programming
    Replies: 7
    Last Post: 24th January 2009, 00:09
  5. How to increase size of QGraphicsView Dynamically
    By Kingofhearts_sri in forum Qt Programming
    Replies: 1
    Last Post: 23rd January 2009, 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.