Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to increase the size of the dialog box at run time?
Forum Updated to NodeBB v4.3 + New Features

How to increase the size of the dialog box at run time?

Scheduled Pinned Locked Moved General and Desktop
8 Posts 4 Posters 4.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    aurora
    wrote on last edited by
    #1

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

    @ void Dialog::Display_header(QStringList headerList)
    {
    for(int i=0;i<headerList.count();i++)
    {
    QRadioButton *Rbutton= new QRadioButton();
    Rbutton->setText(headerList.at(i));
    ui->verticalLayout->addWidget(Rbutton);

    }
    }@
    
    1 Reply Last reply
    0
    • F Offline
      F Offline
      fluca1978
      wrote on last edited by
      #2

      Are you sure there is not a fixed size of the dialog? The layout is correctly set for the dialog?

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #3

        How about you ask the layout of your form for the QLayout::sizeHint(), and then just set that size for the dialog using QWidget::setGeometry() ?

        1 Reply Last reply
        0
        • A Offline
          A Offline
          aurora
          wrote on last edited by
          #4

          ya...i set it in designer....
          [quote author="fluca1978" date="1323853587"]Are you sure there is not a fixed size of the dialog? The layout is correctly set for the dialog? [/quote]

          1 Reply Last reply
          0
          • C Offline
            C Offline
            Chris H
            wrote on last edited by
            #5

            Have you made sure to set the QDialog's main layout? The easiest way in Qt Designer is to make sure you have deselected everything, and then choose "Lay out horizontally" or one of the other layout-creation options.

            1 Reply Last reply
            0
            • F Offline
              F Offline
              fluca1978
              wrote on last edited by
              #6

              The following code works for me:

              @void MainWindow::createButtons()
              {

              QWidget* widget = new QWidget( this );
              setCentralWidget( widget );
              verticalLayout = new QVBoxLayout( this );
              widget->setLayout(verticalLayout);
              
              for( int i = 0; i < 10; i++ ){
              
                  QString s = "Button # %1";
                  s = s.arg( i );
              
                  qDebug()<< "Adding button " << i << " " << s;
              
                  verticalLayout->addWidget( new QPushButton( s, widget ) );
              }
              

              }
              @

              I guess the problem could be related to the main/central widget layout, as pointed out by Chris.

              1 Reply Last reply
              0
              • C Offline
                C Offline
                Chris H
                wrote on last edited by
                #7

                Oops, sorry for the terminology goof, "central" was the word I was looking for, not "main": I had this same problem last week and it turned out that's what I was messing up. If you don't set the central widget for your dialog then when you resize the window nothing happens to the widgets inside it, since they don't know they are supposed to be connected.

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  aurora
                  wrote on last edited by
                  #8

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

                  @void Dialog::Display_header(QStringList headerList)
                  {

                  for(int i=0;i&lt;headerList.count();i++)
                  {
                      QRadioButton *Rbutton= new QRadioButton();
                  
                      Rbutton-&gt;setText(headerList.at(i));
                      ui->verticalLayout->addWidget(Rbutton);
                     ui->verticalLayout->setAlignment(Qt::AlignTop);
                  
                     ui->verticalLayout->setSpacing(1);
                     ui->verticalLayout->setStretch(1,1);
                  }
                  

                  }
                  @

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved