Results 1 to 15 of 15

Thread: QToolBox + resize + hide

  1. #1
    Join Date
    Nov 2006
    Posts
    96

    Default QToolBox + resize + hide

    Hi, this is my code now:

    Qt Code:
    1. m_pToolbox = new QToolBox();
    2. Q_CHECK_PTR(m_pToolbox);
    3.  
    4.  
    5. m_pTabSifrant = new QTabWidget();
    6. Q_CHECK_PTR(m_pTabSifrant);
    7. m_pTabVnos = new QTabWidget();
    8. Q_CHECK_PTR(m_pTabVnos);
    9. m_pTabIsci = new QTabWidget();
    10. Q_CHECK_PTR(m_pTabIsci);
    11. m_pTabNatisni = new QTabWidget();
    12. Q_CHECK_PTR(m_pTabNatisni);
    13.  
    14. //tabs
    15. m_pToolbox->addItem(m_pTabSifrant,trUtf8("Šifranti"));
    16. m_pToolbox->addItem(m_pTabVnos,trUtf8("Vnos"));
    17. m_pToolbox->addItem(m_pTabIsci,trUtf8("Iskanje"));
    18. m_pToolbox->addItem(m_pTabNatisni,trUtf8("Tiskanje"));
    19.  
    20. //add QToolBox to the main widget
    21. m_pMainLayout->addWidget(m_pToolbox);
    22. //set stretch factor to 1
    23. m_pMainLayout->setStretchFactor(m_pToolbox,1);
    24.  
    25. //add blank widget to main widget --> we'll have to change that to insert a widget we'll use. This is just for testing purposes
    26. QWidget *test = new QWidget();
    27. m_pMainLayout->addWidget(test);
    28. m_pMainLayout->setStretchFactor(test,3);
    To copy to clipboard, switch view to plain text mode 


    Now I want a way to resize and hide the QToolBox, like in kpdf program. There's a little sidebar (where the slides are in minimal form) and you can resize it and hide it. When it's hidden you can also drag it on the right again to show it..


    How can I do that.

  2. #2
    Join Date
    Nov 2006
    Posts
    96

    Default Re: QToolBox + resize + hide


  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QToolBox + resize + hide

    Take a look at QSplitter.
    J-P Nurmi

  4. #4
    Join Date
    Nov 2006
    Posts
    96

    Default Re: QToolBox + resize + hide

    Hi. That was a good tip man:

    Qt Code:
    1. splitter = new QSplitter();
    2. Q_CHECK_PTR(splitter);
    3.  
    4. //tabs
    5. m_pToolbox->addItem(m_pTabSifrant,trUtf8("Šifranti"));
    6. m_pToolbox->addItem(m_pTabVnos,trUtf8("Vnos"));
    7. m_pToolbox->addItem(m_pTabIsci,trUtf8("Iskanje"));
    8. m_pToolbox->addItem(m_pTabNatisni,trUtf8("Tiskanje"));
    9.  
    10. //add QToolBox to the splitter widget
    11. splitter->insertWidget(0,m_pToolbox);
    12.  
    13. //add blank widget to splitter widget --> we'll have to change that to insert a widget we'll use. This is just for testing purposes
    14. QWidget *test = new QWidget();
    15. splitter->insertWidget(1,test);
    16.  
    17. //sets whether the child at index is collapsible to collapse
    18. splitter->setCollapsible(0,true);
    19. splitter->setCollapsible(1,false);
    20. //set's the stretch factor to specific widget
    21. splitter->setStretchFactor(0,1);
    22. splitter->setStretchFactor(1,3);
    23.  
    24. //sets the size of the 2 widgets in QSplitter
    25. QList<int> m_SizeList;
    26. m_SizeList << 100 << 500;
    27. splitter->setSizes(m_SizeList);
    28.  
    29.  
    30. //add QSplitter to the main widget
    31. m_pMainLayout->addWidget(splitter);
    To copy to clipboard, switch view to plain text mode 

    Now the only thing I want to do is to let the QToolBox resize only 1/3 of the screen (that would be the maximum width for that widget). I've looked everywhere to find function for that, but I couldn't find it. Any tips?

  5. #5
    Join Date
    Nov 2006
    Posts
    96

    Default Re: QToolBox + resize + hide

    When QToolBOx is hidden, it now looks like this:



    and I want it to look like this:



  6. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QToolBox + resize + hide

    Now the only thing I want to do is to let the QToolBox resize only 1/3 of the screen (that would be the maximum width for that widget). I've looked everywhere to find function for that, but I couldn't find it. Any tips?
    you could overload resizeEvent().

    When QToolBOx is hidden, it now looks like this:
    in the second image we see the inner edge of a main window - but what do we see in the first?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  7. #7
    Join Date
    Nov 2006
    Posts
    96

    Default Re: QToolBox + resize + hide

    In the first image you see the closed QToolBox as you do in the second image (if you grab it and go right, the QToolBox openes...)

    I just want this closed QToolBox to be on the left corner of the main widget (like in second picture) and not a few inches to the right.

  8. #8
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QToolBox + resize + hide

    I just tried it, and i get no such left margins...
    are you sure you placed the whole splitter layout on the inner edge of the main widget?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  9. #9
    Join Date
    Nov 2006
    Posts
    96

    Default Re: QToolBox + resize + hide

    Can you post your code somewhere so I can test if your's are displays by the left cornet correctly...

    Thanks

  10. #10
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QToolBox + resize + hide

    oh, I know now what you mean.
    What you see, is the splitter "handle".
    You can adjust its width with setHandleWidth () or in designer in the property editor.

    the open image is with handle width 5 and the closed with width 2.
    Attached Images Attached Images
    Last edited by high_flyer; 24th October 2007 at 17:24.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  11. #11
    Join Date
    Nov 2006
    Posts
    96

    Default Re: QToolBox + resize + hide

    No no, I mean I want to get rid of the space between MainWindow frame and handle.

  12. #12
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QToolBox + resize + hide

    but as you can see in the images, there is no space between the MainWindow frame and the handle.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  13. #13
    Join Date
    Nov 2006
    Posts
    96

    Default Re: QToolBox + resize + hide

    In your case yes, but the first picture of mine there is space...and I don't have any other widgets there.

  14. #14
    Join Date
    Nov 2006
    Posts
    96

    Default Re: QToolBox + resize + hide

    Ok, I'll survive without this. But have another question:

    How can I save the size the user set. Let's say the user run the program for the first time and then he want's to have the same size of the QToolBox every time he run's the program again. How to do that?

  15. #15
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QToolBox + resize + hide

    Use QSplitter::saveState() and QSplitter::restoreState() together with QSettings. Notice examples in docs.
    J-P Nurmi

Similar Threads

  1. Simple frame control doesn't resize when I hide()
    By MrGarbage in forum Qt Programming
    Replies: 2
    Last Post: 29th August 2007, 23:32
  2. postponing resize event
    By Honestmath in forum Qt Programming
    Replies: 11
    Last Post: 26th February 2006, 01:32

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.