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 fix the width scale ratio of central widget to mainwindow which contains dockwidgets

How to fix the width scale ratio of central widget to mainwindow which contains dockwidgets

Scheduled Pinned Locked Moved General and Desktop
mainwindowdockwidgetcentral widget
3 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.
  • J Offline
    J Offline
    JohnYork
    wrote on 25 May 2015, 13:29 last edited by
    #1

    Hello everyone !
    I have a mainwindow with some dockwidgets docked at the right side of it. And I also place a central widget in mainwindow. I want to keep the central widget's width as a fixed scale ratio to mainwindow's width, and the dockwidgets at right side occupy the remained width.

    I found that there is a property in central widget's layout with name of 'layoutStretch', but it seemed that could not make central widget work as I wish.

    Could anyone tell me some instruction ? thanks a lot!

    1 Reply Last reply
    1
    • J Offline
      J Offline
      Jakob
      wrote on 25 May 2015, 18:13 last edited by
      #2

      I don't have a ready-made solution for you, but I can tell you at least that:

      • layoutStretch is the wrong place to look for - this is a technique that allows you to set 'weights' for elements that are handled by the same layout (as far as I understand)
      • I'd start looking for the resizeEvent() member of the QMainWindow class (it is defined in QWidget) - reimplement that function and have it resize the central widget based on your desired scale ratio
      J 1 Reply Last reply 26 May 2015, 12:17
      0
      • J Jakob
        25 May 2015, 18:13

        I don't have a ready-made solution for you, but I can tell you at least that:

        • layoutStretch is the wrong place to look for - this is a technique that allows you to set 'weights' for elements that are handled by the same layout (as far as I understand)
        • I'd start looking for the resizeEvent() member of the QMainWindow class (it is defined in QWidget) - reimplement that function and have it resize the central widget based on your desired scale ratio
        J Offline
        J Offline
        JohnYork
        wrote on 26 May 2015, 12:17 last edited by
        #3

        @Jakob
        Thanks, Mr. Jakob. I'd tried to resize central widget in resizeEvent(), I found it seemed that setting the geometry of the central widget's layout could work, but not worked good completely. One of the problems is : the docked widgets's width do not change synchronously, this problem cause spacing or overlapping appeares between central widget and docking widgets while resizing mainwindow.

        I thought maybe I should call 'updateGeometry' for every docked widget, but I have not enough time to verify this guess. would you please tell me?

        Well, there is another question about dockwidget and mainwindow:
        I found there was an internal splitter between central widget and docking widgets, and if I pressed mouse left button and pulled it to another position, the docking widgets's width would be fixed and could only be changed by pulling the splitter. This problem makes my purpose to unreached too. How can I work around it?

        1 Reply Last reply
        0

        1/3

        25 May 2015, 13:29

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved