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. How to set QTreeview.width == MainWindow.width
Forum Updated to NodeBB v4.3 + New Features

How to set QTreeview.width == MainWindow.width

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.4k 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.
  • X Offline
    X Offline
    xkiz
    wrote on last edited by
    #1

    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)!

    Sent from Ubuntu

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

      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.

      1 Reply Last reply
      0
      • X Offline
        X Offline
        xkiz
        wrote on last edited by
        #3

        Thanks, I didn't see that.

        Sent from Ubuntu

        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