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. Make QTableWidget expand when dialog window size is changed

Make QTableWidget expand when dialog window size is changed

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 5.8k Views
  • 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.
  • P Offline
    P Offline
    petergeng
    wrote on last edited by
    #1

    I have a tablewidget, and a textEdit, and cancel +okay bottons
    I want these widgets to stay in the relative position to each other, and the tablewidget to expand if the dialog window is expanded or size changed...

    how can i do that?

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

      Use a layout manager, "gridlayout":http://doc.qt.nokia.com/latest/qgridlayout.html should work for you.

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

        Please read the "introduction on layout management":http://doc.qt.nokia.com/latest/layout.html from the documentation.

        For positioning the cancel and OK buttons, I would recommend you look into using a QDialogButtonBox. It will automatically layout and order the buttons for you in the way your platform prescribes.

        1 Reply Last reply
        0
        • P Offline
          P Offline
          petergeng
          wrote on last edited by
          #4

          so i have this
          @QGridLayout *layout=new QGridLayout();
          ui->tableWidget->setSizePolicy(QSizePolicy::Expanding);
          layout->addWidget(ui->tableWidget,0,0,-1,-1,Qt::AlignVCenter);
          layout->addWidget(ui->textEdit_2,1,0,1,2,Qt::AlignLeft);
          layout->addWidget(ui->cancel,1,1);
          layout->addWidget(ui->ok,1,2);
          this->setLayout(layout); @

          but only a tiny box is created for viewing of each widget... the widget doesnt fill up the cell in the grid... and the setSizePolicy gave me error of it being private and cant be accessed.... ???

          1 Reply Last reply
          0
          • P Offline
            P Offline
            petergeng
            wrote on last edited by
            #5

            although the widgets, buttons do change position and size with respect to the parent dialog window

            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