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. Setting different sizes to tabified QDockWidget?

Setting different sizes to tabified QDockWidget?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 2.7k 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.
  • N Offline
    N Offline
    never_ever
    wrote on last edited by
    #1

    Hi,
    I have some QDockWidgets objects that was tabified. Now I want to have sth like this:

    • when one of the tabs is active I can resize that docked widget (I'm changing only height of it, width is the same as mainwindow)
    • then for example I change to other tab and resize that docked widget (to different height than first dock widget)
    • then I back to previous tab and I want to have that dock widget in size I left it, not in size of second tab

    Is it possible to do this?

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

      Hi,

      What you could try is to keep a hash containing your QDockWidget pointers as key and their corresponding heights as value, then add a slot to your QMainWindow that reacts on the visibility changed signal of QDockWidget and update the size of the newly visible widget.

      Hope it helps

      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
      • N Offline
        N Offline
        never_ever
        wrote on last edited by
        #3

        I have tried to do this by saving last height of QDockWidget but I can't resize QDockWidget. Somewhere I read that there is problem with resizing QDockWidget because QMainWindow controls it's size (or sth common).

        EDIT:
        Ok, solved. It was enough to set maximum and minimum size to previous saved size and then add processEvents() and return to max and min default values.

        @
        void MyDockWidget::setDockSize(bool isVisible)
        {
        if(isVisible)
        {
        if(m_firstUse)
        m_firstUse = false;

          setMaximumHeight(m_previousHeight);
          setMinimumHeight(m_previousHeight);
          QApplication::processEvents();
          setMaximumHeight(m_defaultHeight);
          setMinimumHeight(1);  
        }
        else
        {
          if(m_firstUse)
            m_previousHeight = 1;
          else 
            m_previousHeight = size().height();
        

        }

        @

        I'm only wondering why I have to set minimum height to 1, I can't set it to 0 because then signal visibilityChanged(bool) is not called. And this signal is linked with my slot setDockSize.

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

          Probably because a size of zero implies that your widget is invisible

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

            Maybe you are right. For now, I leave minimum size set to 1. Maybe I will think about solve this problem later.

            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