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. QVBoxLayout give to much horizontal space to QTableView

QVBoxLayout give to much horizontal space to QTableView

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

    Dear All:

    I am trying to Layout a QWidget that contain a QTableView a QPushButton, for that I am using a QVBoxLayout the problem I am having is that the QVBoxLayout is to big for the size of QTableView. I will expect the QVBoxLayout to be able to fit to the QTableView size but I am having a lot of space horizontally.

    The code I am using is as follow:

    @/ Create the Objects in the Dialog
    channelSelectionList_ = new TraceOverlayChannelSelectionList(channels, targetChannelId);

    closeButton_ = new QPushButton(tr("&Finish"));
    connect(closeButton_, SIGNAL(clicked()), this, SLOT(finished_()));
    
    // Layout Objects
    QVBoxLayout *layout = new QVBoxLayout;
    layout->addWidget(channelSelectionList_);
    layout->addWidget(closeButton_);
    setLayout(layout);
    

    @

    Thanks a lot for any help I can get
    Ernesto

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      bq. the QVBoxLayout is to big for the size of QTableView.

      What do you mean by that? QTableView is positioned and sized using the layout, so what do you mean it's too big for size?

      bq. I will expect the QVBoxLayout to be able to fit to the QTableView size but I am having a lot of space horizontally.

      The layout is not inside the table view. It doesn't fit anything. It lays out widgets assigned to it. Where exactly is the space? Can you describe what you're getting and what you want a little more? Or show a picture of expected result?

      1 Reply Last reply
      0
      • E Offline
        E Offline
        epalmero
        wrote on last edited by
        #3

        Sorry can you please tell me how to add a picture here.

        Sorry for the stupid question

        1 Reply Last reply
        0
        • Chris KawaC Offline
          Chris KawaC Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Sure, unfortunately this forum does not host pictures directly. You need to upload it to some external hosting site like tinypic.com or photobucket.com. Then copy the link they generate and paste here using the photo button (around the middle of the button bar above the text).

          1 Reply Last reply
          0
          • E Offline
            E Offline
            epalmero
            wrote on last edited by
            #5

            Thanks a lot please find here the link with the image. As you can see the horizontal width of the QWidget holding the QTableView is to big.

            https://dl.dropboxusercontent.com/u/64570880/Capture.JPG

            All the best and thanks again
            Ernesto

            1 Reply Last reply
            0
            • Chris KawaC Offline
              Chris KawaC Offline
              Chris Kawa
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Sorry, but I don't get it. It looks ok to me.

              If you mean the space to the left and right, outside of the table then these are margins controlled by "setContentsMargins":http://doc.qt.io/qt-5/qlayout.html#setContentsMargins method of the layout. Set them to 0 or whatever you want.

              If you mean the white space inside the table then if you want to set the table to specific width you can use its method "setFixedWidth":http://doc.qt.io/qt-5/qwidget.html#setFixedWidth for that.

              1 Reply Last reply
              0
              • E Offline
                E Offline
                epalmero
                wrote on last edited by
                #7

                I have update the image with a red rectangle where I think the space should not be there. For me the QVBoxLayout should remove all that empty space.

                Thanks
                Ernesto

                1 Reply Last reply
                0
                • Chris KawaC Offline
                  Chris KawaC Offline
                  Chris Kawa
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  It's a vertical layout so it only manages the vertical size of the widgets. In horizontal axis they get as much space as there is, unless they specify a maximum amount they can use.
                  For that you can use either the setFixedWidth method I mentioned or setMaximumWidth if you want to let it shrink.

                  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