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. rows don't span in a grid layout.

rows don't span in a grid layout.

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 268 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.
  • N Offline
    N Offline
    ntos
    wrote on last edited by
    #1

    Hi,

    Here is the code:

    Dialog::Dialog(QWidget *parent)
        : QDialog(parent)
        , ui(new Ui::Dialog)
    {
        ui->setupUi(this);
        QGridLayout* glayout = new QGridLayout(this);
        QPushButton* pushButton = new QPushButton("span");
        glayout->addWidget(pushButton, 0, 0, 2, 2);
        glayout->addWidget(new QPushButton("normal"),2,0);
    
    }
    The result: 
    ![Screenshot from 2024-06-18 14-59-16.png](https://ddgobkiprc33d.cloudfront.net/0e129064-446e-4d60-a117-d04a6703e853.png) 
    

    Why doesn't the row span to the next row like the column?

    Thank you.

    C 1 Reply Last reply
    0
    • N ntos

      Hi,

      Here is the code:

      Dialog::Dialog(QWidget *parent)
          : QDialog(parent)
          , ui(new Ui::Dialog)
      {
          ui->setupUi(this);
          QGridLayout* glayout = new QGridLayout(this);
          QPushButton* pushButton = new QPushButton("span");
          glayout->addWidget(pushButton, 0, 0, 2, 2);
          glayout->addWidget(new QPushButton("normal"),2,0);
      
      }
      The result: 
      ![Screenshot from 2024-06-18 14-59-16.png](https://ddgobkiprc33d.cloudfront.net/0e129064-446e-4d60-a117-d04a6703e853.png) 
      

      Why doesn't the row span to the next row like the column?

      Thank you.

      C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      @ntos What makes you think it does not? The QPushButton will not grow vertically and yoiu have nothing else to reference it to in those rows. See this, for example:

      #include <QApplication>
      #include <QGridLayout>
      #include <QFrame>
      #include <QPushButton>
      #include <QWidget>
      
      int main(int argc, char **argv) {
              QApplication app(argc, argv);
      
              QWidget w;
              QGridLayout* glayout = new QGridLayout(&w);
              QPushButton* pushButton = new QPushButton("span");
              glayout->addWidget(pushButton, 0, 0, 2, 2);
              glayout->addWidget(new QPushButton("normal"),2,0);
      
              QFrame *frame = new QFrame(&w);
              frame->setFrameStyle(QFrame::Box | QFrame::Plain);
              glayout->addWidget(frame, 0, 2);
              frame = new QFrame(&w);
              frame->setFrameStyle(QFrame::Box | QFrame::Plain);
              glayout->addWidget(frame, 1, 2);
              frame = new QFrame(&w);
              frame->setFrameStyle(QFrame::Box | QFrame::Plain);
              glayout->addWidget(frame, 2, 2);
      
              w.resize(640, 480);
              w.show();
      
              return app.exec();
      }
      

      Result:
      2d17d2ba-802a-432d-8aa7-c3aaa48b574e-image.png

      1 Reply Last reply
      1
      • N Offline
        N Offline
        ntos
        wrote on last edited by
        #3

        @ChrisW67 . Thank you. I forgot to set the size policy for the vertical dimension.

        1 Reply Last reply
        0
        • N ntos has marked this topic as solved on

        • Login

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