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. QSplitter - sizes() return 0?
Forum Updated to NodeBB v4.3 + New Features

QSplitter - sizes() return 0?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 2.0k 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
    maximus
    wrote on last edited by
    #1

    I'm having problem setting initial sizes for my QSplitter. What's odd is if I check the initial sizes before setting them with "ui->splitter->sizes();" I get 0 for both layout inside the QSplitter.

    The check is made after the setupUI call, I have tried many things but it always return me 0 for sizes. What's even more odd is that I have another GUI similar that is working with a QSplitter. If anyone have experience with this kind of problem with QSplitter any help would be appreciated!

    See my interface here :
    https://www.dropbox.com/s/4sc0hae393ur5fg/splitterPRob.png

    I tried changing the vertical layout to a grid layout like #2, still not working, any ideas appreciated ;)
    Qt doc says : Note that invisible widgets have a size of 0. : both of my widget are visible!

    @ QList<int> sizeNow = ui->splitter->sizes();
    for(int i=0; i<sizeNow.length(); i++) {
    qDebug() << "SIZE here" << sizeNow.at(i); /// return 0...
    }@


    Free Indoor Cycling Software - https://maximumtrainer.com

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      Hope splitter is displayed with splitter.show(). If the splitter is not shown, size is not set. It will set sizes only if they are shown.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      0
      • M Offline
        M Offline
        maximus
        wrote on last edited by
        #3

        Hi,

        Yes the splitter is show and working, the problem is only getting it's initial sizes (return 0) and settings it's size.
        The splitter is added directly inside the ui file (designer)


        Free Indoor Cycling Software - https://maximumtrainer.com

        1 Reply Last reply
        0
        • dheerendraD Offline
          dheerendraD Offline
          dheerendra
          Qt Champions 2022
          wrote on last edited by
          #4

          QSplitter will get the sizes only if the widgets inside the splitter are shown. Otherwise it returns zero.

          @ // See the code snippet. It shows correct result
          split.show();
          QList<int> sizes = split.sizes();
          for(int i=0;i<sizes.length();i++){
          qDebug() << "Hello =" << sizes.at(i); // Returns the size
          }

          // See the below code snippet. It return zero
          QList<int> sizes = split.sizes(); 
          split.show();
          for(int i=0;i<sizes.length();i++){
              qDebug() << "Hello =" << sizes.at(i); // Returns the ZERO
          }@
          

          Dheerendra
          @Community Service
          Certified Qt Specialist
          http://www.pthinks.com

          1 Reply Last reply
          0
          • M Offline
            M Offline
            maximus
            wrote on last edited by
            #5

            Hi,

            I added a .show() before just to make sure :

            @ ui->splitter->show();
            QList<int> sizeNow = ui->splitter->sizes();
            for(int i=0; i<sizeNow.length(); i++) {
            qDebug() << "SIZE here" << sizeNow.at(i);
            }@

            log :
            SIZE here 0
            SIZE here 0

            I have a QHBoxLayout and a custom QWidget in the Vertical splitter. both are shown on the screen and visible..


            Free Indoor Cycling Software - https://maximumtrainer.com

            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