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. More Layout queries...
Forum Updated to NodeBB v4.3 + New Features

More Layout queries...

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

    Here is the form:
    image001.png
    Here is the structure:
    image002.png
    What I would like to do is have the QGroupBox span the width of the form, for some reason that escapes me, perhaps because the layout is a QFormLayout the group has to occupy the right column.

    Is there anyway for it to span both columns or would it be easier to use another QGridLayout ?

    Kind Regards,
    Sy

    1 Reply Last reply
    0
    • T Offline
      T Offline
      TheGringerEye
      wrote on last edited by
      #2

      https://doc.qt.io/qt-5/layout.html

          QWidget *window = new QWidget;
          QPushButton *button1 = new QPushButton("One");
          QPushButton *button2 = new QPushButton("Two");
          QPushButton *button3 = new QPushButton("Three");
          QPushButton *button4 = new QPushButton("Four");
          QPushButton *button5 = new QPushButton("Five");
      
          QGridLayout *layout = new QGridLayout(window);
          layout->addWidget(button1, 0, 0);
          layout->addWidget(button2, 0, 1);
          layout->addWidget(button3, 1, 0, 1, 2);
          layout->addWidget(button4, 2, 0);
          layout->addWidget(button5, 2, 1);
      
          window->show();
      
      

      The third QPushButton spans 2 columns. This is possible by specifying 2 as the fifth argument to QGridLayout::addWidget().

      I try to learn English.

      SPlattenS 1 Reply Last reply
      1
      • T TheGringerEye

        https://doc.qt.io/qt-5/layout.html

            QWidget *window = new QWidget;
            QPushButton *button1 = new QPushButton("One");
            QPushButton *button2 = new QPushButton("Two");
            QPushButton *button3 = new QPushButton("Three");
            QPushButton *button4 = new QPushButton("Four");
            QPushButton *button5 = new QPushButton("Five");
        
            QGridLayout *layout = new QGridLayout(window);
            layout->addWidget(button1, 0, 0);
            layout->addWidget(button2, 0, 1);
            layout->addWidget(button3, 1, 0, 1, 2);
            layout->addWidget(button4, 2, 0);
            layout->addWidget(button5, 2, 1);
        
            window->show();
        
        

        The third QPushButton spans 2 columns. This is possible by specifying 2 as the fifth argument to QGridLayout::addWidget().

        SPlattenS Offline
        SPlattenS Offline
        SPlatten
        wrote on last edited by
        #3

        @TheGringerEye , thank you, I'm in the process of replacing QFormLayout with QGridLayout.

        Kind Regards,
        Sy

        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