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. Qt Layout doesn't work with plain widget

Qt Layout doesn't work with plain widget

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 897 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
    xalam
    wrote on last edited by
    #1

    I am using a plain widget which shows QCustomPlot. I have splitter with two panes, left pane is a QTreeView and right pane is the plot.

    Now I am trying to couple other controls in right pane but it does let me me. I want to set QCustomePlot with QLabel on top and than these two will appear in the right pane of splitter but when I group them together using vertical layout, they both overlaps and it doesn't show up correctly.

    How can I fix this problem? Thanks

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You have to use a container widget for that so something like:
      @
      QWidget *container = new QWidget;
      QVBoxLayout *vLayout = new QVBoxLayout(container);
      vLayout->addWidget(myLabel);
      vLayout->addWidget(customPlot);
      mySplitter->addWidget(container);
      @

      Hope it helps

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

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

        Thanks, that worked! I was able to do it with from Qt Creator itself, place widget and label inside another widget and setting the grid layout.

        If someone else is doing similar thing, another nice thing I did to to set the layout nice is for QLabel, I set the vertical sizePolicy to maximum and horizental sizePolicy to 'ignored'. This created the perfect layout that I wanted otherwise the QLabel will take more space in the division.

        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