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. Problems with Splitters
Forum Updated to NodeBB v4.3 + New Features

Problems with Splitters

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 590 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.
  • M Offline
    M Offline
    mjsmithers
    wrote on last edited by mjsmithers
    #1

    Hi,

    I'd appreciate any guidance here.

    I have a program with a tab view and on each of the tabs there are horizontal splitters. At program start I want to set the width of the left side of the splitters to a value (e.g. 360) that I know is < half the width of the MainWindow (e.g. 900). (Using these example numbers, I would call setSizes() with 360 and 900-360 = 540.)

    Initially I called setSizes() in the MainWindow constructor and found it didn't work; I presume because the splitters haven't been rendered yet and therefore the size available to them isn't know. I then added code to do one-time set in the showEvent() and an everytime set in the resizeEvent(). This works! However....

    On rare occasions I find one of the splitters still isn't set correctly. It's always the same one and its split point is completed to the right hand side, as if the width available was extremely small (< 100) and my setting code set the widths to [360, 100-360 = -260] which is clearly invalid.

    The problem only appears occasionally when running a release build, and so I can't debug it.

    One other caveat, in the MainWindow constructor I remove some tabs (which contain splitters) from the tab view, depending on a mode of the program, and the splitter with the problem is one of these tabs which is not attached to the tab view when showEvent() is called. (showEvent() still does set its sizes.) Later switching the program mode causes this tab and some others to be reinserted into the tab view, but only one of these reinserted tabs has a problem with its splitter.

    So I guess my question are;

    • when is the best time to call splitter setSizes() to set the initial split point?
    • what does setSizes() do if the splitter (or its parent widget) is not directly associated with the tab view? Are they still children and therefore get sent size information? In my experience the setSizes() still works 99% of the time.

    Thanks,

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

      Hi,

      Does that widget triggering the issue have anything special in it ?

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

      M 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Does that widget triggering the issue have anything special in it ?

        M Offline
        M Offline
        mjsmithers
        wrote on last edited by
        #3

        @SGaist Do you mean the tab that contains the splitter that's occasionally problematic? I'll check but I'm fairly sure there's nothing on this tab and inside the splitter, that's different to what's on other tabs.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mjsmithers
          wrote on last edited by
          #4

          Ok, I returned to these splitters again and discovered something new.

          When QSplitters are on tabs in a QTabWdiget, the splitters don't set up their layout until the tab is visible, and so it's impossible to force a splitter handle location until the first time the tab (containing the splitter) is visible.

          So for each tab in my application, I have to use a unique "first show" boolean which I use to set the splitter split position on QTabWidget::currentChanged(int).

          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