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

Layout tutorial wanted

Scheduled Pinned Locked Moved General and Desktop
8 Posts 4 Posters 2.1k 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.
  • D Offline
    D Offline
    deleted28
    wrote on last edited by
    #1

    Can anyone here recommend a clear and comprehensive tutorial on Qt Layouts ?
    I'm totally confused on this topic by reading always partial descriptions on single
    simple solutions but do not get the general philosophy behind the concepts.
    Thanks!

    1 Reply Last reply
    0
    • X Offline
      X Offline
      Xander84
      wrote on last edited by
      #2

      http://qt-project.org/doc/qt-5/layout.html (that is more for widget layouts, not QML but I guess you don't want to use QML for your layouts?)
      also there are many examples shipped with Qt Creator itself.

      1 Reply Last reply
      0
      • EddyE Offline
        EddyE Offline
        Eddy
        wrote on last edited by
        #3

        Yes, there is a lot to read about layouts. But maybe we can help you on the right track by assisting in making your specific dialog with layouts in it. You could make a picture of what you want and we can guide you through.

        Qt Certified Specialist
        www.edalsolutions.be

        1 Reply Last reply
        0
        • D Offline
          D Offline
          deleted28
          wrote on last edited by
          #4

          thank you for this suggestion, but i do not have a specific layout problem.
          In some way (trial & error) i fixed the most designs i needed so far.
          But i do not understand the systematic.
          Most confusing is sizepolicy-settings. When it affects childs and when it's own behavior in a parent. What is a sizehint and where it comes from ?
          When right-click on a widget in a Layout and select "size constraints",
          what does the set Minimum , set maximum do ? It does not set a size but seems to set "yes, use minimum size settings". And of course "prferred"
          "minimum expanding", "ignore" and so on. How are "size constraints" and
          "size policies" related to each other ?
          I'm already so messed up, that even my questions are stupid i think.

          1 Reply Last reply
          0
          • EddyE Offline
            EddyE Offline
            Eddy
            wrote on last edited by
            #5

            Everything you talk about is well explained in chapter 6 of this book:

            C++  GUI Programming with Qt 4 (2nd Edition) - The official C++/Qt book
            Author: Jasmin Blanchette and Mark Summerfield
            ISBN: 0132354160 / 978-0132354165

            i would recommend reading it.

            Qt Certified Specialist
            www.edalsolutions.be

            1 Reply Last reply
            0
            • D Offline
              D Offline
              deleted28
              wrote on last edited by
              #6

              I want to come back to Eddy's suggestion and ask a precise question.
              Assuming i have a QGroupBox with a QVBoxLayout with Topalignment
              and adding widgets to it. When the vertical space needed by these added widgets exceeds the height of the QGroupBox and i add even more widgets, the QGroupBox height grows and also its parent (centralwidget).
              How to implement a vertical scrollbar to the QGroupBox which gets visible
              when the required space by added new widgets exceeds the availbale height of this GroupBox ?. I do not want the growing QGroupBox makes its parent grow.

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Hi,

                You would need a "QScrollArea":http:// as "main widget" inside your QGroupBox

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  deleted28
                  wrote on last edited by
                  #8

                  That is what i achieved so far. In some way it works.
                  Seems i can not attach screenshots here, right ?
                  but i'll try to explain question.
                  How to get the widget containing all the Pushbuttons to fit
                  entirely to the width of QGroupbox (parent) but has limited heigth and
                  do not change parent size ?
                  and;
                  Why are the PushButtons also green. The stylesheet sets the background also for all childs ?

                  @MainWindow::MainWindow(QWidget *parent) :
                  QMainWindow(parent),
                  ui(new Ui::MainWindow)
                  {
                  ui->setupUi(this);

                  QVBoxLayout *vb_1 = new QVBoxLayout;
                  
                  QGroupBox *gb_1 = new QGroupBox("gb_1-Title");
                  gb_1->setStyleSheet("background: beige;");
                  vb_1->addWidget(gb_1);
                  
                  QVBoxLayout *vb_2 = new QVBoxLayout;
                  vb_2->setAlignment(Qt::AlignTop);
                  
                  for(int i=0;i<25;i++)
                  {
                      QPushButton *pb_x = new QPushButton;
                      vb_2->addWidget(pb_x);
                  }
                  
                  QWidget *vb_2W = new QWidget;
                  vb_2W->setStyleSheet("background: green;");
                  vb_2W->setLayout(vb_2);
                  
                  QScrollArea *sa_1 = new QScrollArea(gb_1);
                  sa_1->setBackgroundRole(QPalette::Dark);
                  sa_1->setWidget(vb_2W);
                  
                  centralWidget()->setLayout(vb_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