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. Initial Position QSplitter

Initial Position QSplitter

Scheduled Pinned Locked Moved Solved General and Desktop
12 Posts 3 Posters 11.0k 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.
  • ModelTechM Offline
    ModelTechM Offline
    ModelTech
    wrote on last edited by
    #3

    I tried to play with the percentages, but that does not have any effects. The containing widgets are however resizable to a larger and smaller size than what they initially are, so I would expect that there is no problem with the MinimalSizeHits.

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

      What value does height() return ?

      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
      • ModelTechM Offline
        ModelTechM Offline
        ModelTech
        wrote on last edited by
        #5

        It returns the same value 30 independent of the type of the containing widget that may be of a different type (which is what I would expect). Not sure however whether 30 is rather small.

        What is actually not clear to me for the QSplitter::setSizes function is whether the given size values are considered as relative to each other or whether they are considered as absolute values.

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

          You should rather use sizeHint. I'm guessing that you are calling that from the constructor. At that time, the widget has not yet any idea of its final size when shown. All the more since you put your widgets in a "floating" QSplitter. Floating because it doesn't seem to be in any layout or QMainWindow.

          Since 30 is likely less than the minimal size of your other widgets. setSize will use their sizeHint to try to come up with something suitable.

          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
          • VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on last edited by
            #7

            did you try giving the same value to the stretch factor?

            Splitter->setStretchFactor(0,2);
            Splitter->setStretchFactor(1,2);
            

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

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

              @VRonin's solution is indeed cleaner.

              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
              1
              • ModelTechM Offline
                ModelTechM Offline
                ModelTech
                wrote on last edited by ModelTech
                #9

                Thanks to your remark @SGaist on the widget not yet having an idea of its final size at its construction, I have been able to solve it as indicated below. I should call setSize after setting the layout of the widget it is part of. I also applied your hint on using sizeHint.

                    QWidget *TopWidget = new QWidget(this);
                    TopWidget->setLayout(Top);
                    Splitter = new QSplitter(Qt::Vertical);
                    Splitter->addWidget(TopWidget);
                    Splitter->addWidget(Behavior);
                    Splitter->setCollapsible(0, false);
                    Splitter->setCollapsible(1, false);
                
                    QVBoxLayout *Main = new QVBoxLayout;
                    Main->addWidget(Splitter);
                    setLayout(Main);
                
                    QList<int> Sizes;
                    Sizes.append(0.5 * sizeHint().height());
                    Sizes.append(0.5 * sizeHint().height());
                    Splitter->setSizes(Sizes);
                

                The approach of using setStrechFactor instead of setSize does not work...

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

                  Silly question but did you remove the call to setSize when using setStretchFactor ?

                  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
                  • ModelTechM Offline
                    ModelTechM Offline
                    ModelTech
                    wrote on last edited by
                    #11

                    Eh yes, apparently I should not have done so?

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

                      No, no, that was right.

                      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

                      • Login

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