How to set QTreeview.width == MainWindow.width



  • Hi, i'm new in Qt, I started a project, (now), and I'm stuck with the GUI par of the App. I'm on Qt 5.1.0 for Linux 64-bit under ubuntu 12.04 Desktop App. I am ashamed just ffor asking this kind of question what, I don't see how it is done.

    I have a Mainvindow.ui, in it I need to put a QTreeview(X=0 Y, =0, Width = mainwindow.width, .height = maindowindow.height /3)

    so I don't know how to Make the layout to force the QTreeview to take the same width as the mainwindow width.
    I downloaded some src's(Transmissionbt) to see how it is done, but, when I traid to do this, the LayOut push the QTreeview to x = 9 Y = 9, width = mainwindow.width -18, height = mainwindow.height -18.
    just like this image, but only the width:

    !http://s24.postimg.org/cks4412sl/Captura_de_pantalla_de_2013_07_28_00_53_10.png(sample)!


  • Moderators

    Take a look "here":http://qt-project.org/doc/qt-5.1/qtwidgets/layout.html
    This should explain how to work with layouts.

    As for the 9/18 offsets - these are layout margins. These are the default values so that you don't end up with controls touching each other, as it would look bad for buttons, checkboxes etc.

    In your case this is desirable, so select your layout in the designer (in the object tree) and manually change the values of top, bottom, left and right margins to 0.

    As for the height - insert into the layout another empty widget under your treeview. In the Size Policy section set vertical stretch to 1 for the treeview and 2 for the other widget. This will give your treeview the 1/3 height of the containing widget.



  • Thanks, I didn't see that.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.