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. [SOLVED] Problem with mainLayout of Dialog.
QtWS25 Last Chance

[SOLVED] Problem with mainLayout of Dialog.

Scheduled Pinned Locked Moved General and Desktop
6 Posts 4 Posters 2.5k 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.
  • L Offline
    L Offline
    Leon
    wrote on last edited by
    #1

    I have a problem with the mainLayout. I have this:

    @ optionsGroupBox = new QGroupBox();
    optionsGroupBoxLayout = new QGridLayout;
    optionsGroupBoxLayout->addWidget(ui->label, 0,0);
    optionsGroupBoxLayout->addWidget(ui->comboBox, 0,1);
    optionsGroupBoxLayout->addWidget(ui->label_2, 1,0);
    optionsGroupBoxLayout->addWidget(ui->lineEdit, 1,1);
    optionsGroupBoxLayout->addWidget(ui->label_3, 2,0);
    optionsGroupBoxLayout->addWidget(ui->lineEdit_2, 2,1);
    optionsGroupBoxLayout->addWidget(ui->pushButton_3, 2,2);

    optionsGroupBox->setLayout(optionsGroupBoxLayout);
    
    buttonsLayout = new QHBoxLayout;
    buttonsLayout->addStretch();
    buttonsLayout->addWidget(ui->pushButton_2);
    buttonsLayout->addWidget(ui->pushButton);
    
    mainLayout = new QVBoxLayout;
    mainLayout->addWidget(optionsGroupBox);
    mainLayout->addLayout(buttonsLayout);
    setLayout(mainLayout);@
    

    and it looks like:
    !http://img683.imageshack.us/img683/4044/screenshotsaywhat.png(screen)!
    but i want it look like:
    !http://img836.imageshack.us/img836/7202/screenshot1flw.png(screen2)!

    So the question
    What about the space up from the button Browze.. How can it be covered from the above linedit? ( See second screenshot )
    Thanks for any answers :)

    P.S When i say the space up from the button Browze i mean:
    !http://img11.imageshack.us/img11/4044/screenshotsaywhat.png(screen3)!

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goblincoding
      wrote on last edited by
      #2

      [quote author="Leon" date="1315415173"]I have a problem with the mainLayout. I have this:

      @ optionsGroupBox = new QGroupBox();
      optionsGroupBoxLayout = new QGridLayout;
      optionsGroupBoxLayout->addWidget(ui->label, 0,0);
      optionsGroupBoxLayout->addWidget(ui->comboBox, 0,1);
      optionsGroupBoxLayout->addWidget(ui->label_2, 1,0);
      optionsGroupBoxLayout->addWidget(ui->lineEdit, 1,1);
      optionsGroupBoxLayout->addWidget(ui->label_3, 2,0);

      //add an additional layout for the Browse button and second line edit
      QVBoxLayout lineAndBrowseLayout = new QVBoxLayout;
      lineAndBrowseLayout->addWidget(ui->lineEdit_2);
      lineAndBrowseLayout->addWidget(ui->pushButton_3);
      optionsGroupBoxLayout->addLayout(lineAndBrowseLayout, 2,1);*
      
      optionsGroupBox->setLayout(optionsGroupBoxLayout);
      
      buttonsLayout = new QHBoxLayout;
      buttonsLayout->addStretch();
      buttonsLayout->addWidget(ui->pushButton_2);
      buttonsLayout->addWidget(ui->pushButton);
      
      mainLayout = new QVBoxLayout;
      mainLayout->addWidget(optionsGroupBox);
      mainLayout->addLayout(buttonsLayout);
      setLayout(mainLayout);@
      

      [/quote]
      The bit I added above should do the trick. Note, however, that the space available to position (2,1) in the grid (where we're adding the new layout) will be divided equally between the line edit and the Browse button, i.e. they'll be the same size. You may have to play around with constraints a bit to get your ratio of QLineEdit::QPushButton space usage just right.

      http://www.goblincoding.com

      1 Reply Last reply
      0
      • L Offline
        L Offline
        lgeyer
        wrote on last edited by
        #3

        There is a QGridLayout::addWidget() overload which takes a rowSpan and a columnSpan too.
        @
        optionsGroupBoxLayout->addWidget(ui->comboBox, 0,1,1,2);
        optionsGroupBoxLayout->addWidget(ui->lineEdit, 1,1,1,2);
        @
        Will do the trick.

        1 Reply Last reply
        0
        • L Offline
          L Offline
          Leon
          wrote on last edited by
          #4

          k the first answer is ok! :D
          Just not -QVBoxLayout- lineAndBrowseLayout = new -QVBoxLayout-;
          but lineAndBrowseLayout = new QHBoxLayout
          will do what i want.. thanks ;)

          1 Reply Last reply
          0
          • G Offline
            G Offline
            goblincoding
            wrote on last edited by
            #5

            I don't know why, but I always do that! It's like a mini brain rebellion over which I have no control :D

            http://www.goblincoding.com

            1 Reply Last reply
            0
            • A Offline
              A Offline
              andre
              wrote on last edited by
              #6

              On a side-note. The word is "Browse", not "Browze". You also might want to check if you really want to say "Nami".

              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