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. Good practice for using QLayouts?
Forum Updated to NodeBB v4.3 + New Features

Good practice for using QLayouts?

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

    For when I use nested QLayouts should I be using QWidget's between them?
    For example like below or just place the QHBoxLayout in the QVBoxLayout?

        QWidget *menu = new QWidget();
        QVBoxLayout *vboxLayout = new QVBoxLayout();
        QWidget *menu1 = new QWidget();
        vboxLayout->addWidget(menu1);
        QHBoxLayout *hboxLayout = new QHBoxLayout();
        menu1->setLayout(hboxLayout);
        menu->setLayout(vboxLayout);
        
        ``
    JonBJ 1 Reply Last reply
    0
    • J jkwok678

      For when I use nested QLayouts should I be using QWidget's between them?
      For example like below or just place the QHBoxLayout in the QVBoxLayout?

          QWidget *menu = new QWidget();
          QVBoxLayout *vboxLayout = new QVBoxLayout();
          QWidget *menu1 = new QWidget();
          vboxLayout->addWidget(menu1);
          QHBoxLayout *hboxLayout = new QHBoxLayout();
          menu1->setLayout(hboxLayout);
          menu->setLayout(vboxLayout);
          
          ``
      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @jkwok678
      No need to add intervening widgets if not needed, just add layouts onto layouts via https://doc.qt.io/qt-5/qboxlayout.html#addLayout. Adding a child Q[HV]BoxLayout onto a parent Q[HV]BoxLayout is pretty common.

      1 Reply Last reply
      3

      • Login

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