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. Dialog layout spacing issue
Forum Updated to NodeBB v4.3 + New Features

Dialog layout spacing issue

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 288 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.
  • W Offline
    W Offline
    wazzdaman
    wrote on last edited by
    #1

    Hello,

    how can I remove these huge spaces around HSV pickers and over OK/Cancel buttons?

    I tried to change it with setContentsMargins() and setSpacing() without any success.

    Thanks a lot!

    Win10, Qt5.15.8

    dialog.png

    void ColorDialog::createLayout()
    {
        QVBoxLayout* mainLayout = new QVBoxLayout;
        QHBoxLayout* hBoxLayout = new QHBoxLayout;
        QGridLayout* gridLayout = new QGridLayout;
        hBoxLayout->addWidget(hueSatPicker);
        hBoxLayout->addWidget(valPicker);
        gridLayout->addWidget(colorSample, 0, 0, 4, 1);
        gridLayout->addWidget(new QLabel(tr("Hue")), 0, 1, Qt::AlignRight);
        gridLayout->addWidget(hueSpinBox, 0, 2);
        gridLayout->addWidget(new QLabel(tr("Saturation")), 1, 1, Qt::AlignRight);
        gridLayout->addWidget(satSpinBox, 1, 2);
        gridLayout->addWidget(new QLabel(tr("Value")), 2, 1, Qt::AlignRight);
        gridLayout->addWidget(valSpinBox, 2, 2);
        gridLayout->addWidget(new QLabel(tr("Red")), 0, 3, Qt::AlignRight);
        gridLayout->addWidget(redSpinBox, 0, 4);
        gridLayout->addWidget(new QLabel(tr("Blue")), 2, 3, Qt::AlignRight);
        gridLayout->addWidget(blueSpinBox, 2, 4);
        gridLayout->addWidget(new QLabel(tr("Green")), 1, 3, Qt::AlignRight);
        gridLayout->addWidget(greenSpinBox, 1, 4);
        gridLayout->addWidget(new QLabel(tr("Hex")), 3, 1, Qt::AlignRight);
        gridLayout->addWidget(hexLineEdit, 3, 2, 1, 4);
        mainLayout->addLayout(hBoxLayout);
        mainLayout->addLayout(gridLayout);
        mainLayout->addWidget(dialogButtonBox);
        setLayout(mainLayout);
    }
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      On which layout did you apply your custom constraints ?

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

      W 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        On which layout did you apply your custom constraints ?

        W Offline
        W Offline
        wazzdaman
        wrote on last edited by
        #3

        @SGaist I tried on hBoxLayout and gridLayout too.

        Christian EhrlicherC 1 Reply Last reply
        0
        • W wazzdaman

          @SGaist I tried on hBoxLayout and gridLayout too.

          Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          You did not add any spacer items so everything is stretched so it's using the whole size of the dialog.
          I would suggest using the designer for this so you can play around with the different contraints and spacers more easily.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          W 1 Reply Last reply
          1
          • Christian EhrlicherC Christian Ehrlicher

            You did not add any spacer items so everything is stretched so it's using the whole size of the dialog.
            I would suggest using the designer for this so you can play around with the different contraints and spacers more easily.

            W Offline
            W Offline
            wazzdaman
            wrote on last edited by
            #5

            @Christian-Ehrlicher Awesome, spacers did the trick! Thanks a lot!

            1 Reply Last reply
            0
            • W wazzdaman 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