Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. Cannot set specified sizes when using layouts/splitters
Forum Updated to NodeBB v4.3 + New Features

Cannot set specified sizes when using layouts/splitters

Scheduled Pinned Locked Moved C++ Gurus
4 Posts 2 Posters 1.8k 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.
  • A Offline
    A Offline
    ASxa86
    wrote on last edited by
    #1

    I'm running into a very frustrating issue. I set up my GUI in QtDesigner. Everything is laid out perfectly. I add horizontal and vertical splitters to my GUI and resize to fill my Form. Everything is still laid out perfectly. I hit save, close out, and build my application.

    When I run my application, my GUI does not appear as I set it up in QtDesigner. So I reopen QtDesigner and to my surprise the GUI is not laid out the way I had it.

    What is going on? Is there not a way to set up everything in QtDesigner using splitters? Do I have to resize the splitters programmatically? It would be much preferred to not have to do this programmatically if at all possible.

    Any suggestions?

    1 Reply Last reply
    0
    • EddyE Offline
      EddyE Offline
      Eddy
      wrote on last edited by
      #2

      Hi,

      did you use setSizes?

      Qt Certified Specialist
      www.edalsolutions.be

      1 Reply Last reply
      0
      • A Offline
        A Offline
        ASxa86
        wrote on last edited by
        #3

        I did the following steps:

        1. Add widgets to the form.
        2. Set the geometry position/sizes.
        3. Add horizontal splitter.
        4. Set horizontal splitter geometry position/size.
        5. Add vertical splitter with horizontal splitter and another widget as child.
        6. Set vertical splitter geometry position/size.
        7. Save.

        Note: I can do this programmatically no problem.

        @
        const auto osgWindowPixelWidth = 800;
        const auto osgWindowPixelHeight = 450;

        const auto width = this->m_window.vSplitter->width();
        const auto treeViewPixelWidth = (width - osgWindowPixelWidth) / 2;
        const auto propertyViewPixelWidth = width - osgWindowPixelWidth - treeViewPixelWidth;

        QList<int> widths;
        widths.push_back(treeViewPixelWidth);
        widths.push_back(osgWindowPixelWidth);
        widths.push_back(propertyViewPixelWidth);

        this->m_window.hSplitter->setSizes(widths);

        const auto height = this->m_window.vSplitter->height();
        const auto loggerPixelHeight = height - osgWindowPixelHeight;

        QList<int> heights;
        heights.push_back(osgWindowPixelHeight);
        heights.push_back(loggerPixelHeight);

        this->m_window.vSplitter->setSizes(heights);
        @

        The above code works just fine. The problem is, why can't I do this in QtDesigner? Or why have I been unsuccessful at it? Like I said above, I've got everything positioned and sized just perfectly but when I build/run my app the sizes are incorrect.

        1 Reply Last reply
        0
        • EddyE Offline
          EddyE Offline
          Eddy
          wrote on last edited by
          #4

          AFAIK you have to do this using code like you did. The "sizes" property isn't available in designer and i see no other way to do it, sorry.

          Qt Certified Specialist
          www.edalsolutions.be

          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