Results 1 to 13 of 13

Thread: Subclassing QToolBox

  1. #1
    Join Date
    May 2006
    Posts
    108
    Thanks
    35
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Question Subclassing QToolBox

    Hello,

    i want to expand more than one page form a QToolBox. To do that i try to overwrite QToolBox::setCurrentIndex(int index). It works, but the problem is to use the following code form the original ToolBox within my subclass:

    Qt Code:
    1. Q_D(QToolBox);
    2. QToolBoxPrivate::Page *c = d->page(index);
    3. if (!c || d->currentPage == c)
    4. return;
    To copy to clipboard, switch view to plain text mode 

    The compiler output is: incomplete type 'QToolBoxPrivate' used in nested name specifier...

    I don't understand how can i use the D-Pointer to access d->currentPage. Can you help me please?
    Last edited by whitefurrows; 22nd February 2012 at 18:17.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Subclassing QToolBox

    Your subclass does not have access to either the private d pointer, or the private implementation class. They are private for a good reason. Further, setCurrentIndex() is not virtual and clearly not designed to be replaced.

    I do not understand what you mean by "i want to expand more than one page form a QToolBox" so I have no suggestion as to how to do this.

  3. The following user says thank you to ChrisW67 for this useful post:

    whitefurrows (2nd March 2012)

  4. #3
    Join Date
    May 2006
    Posts
    108
    Thanks
    35
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Question Re: Subclassing QToolBox

    I have attached a image to explain what i mean
    toolbox.png
    You understand and can help me?

  5. #4
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Subclassing QToolBox

    Create proper widget from a scratch as I don't think there's such widget available in Qt.

    It should be fairly simple, just bunch of buttons in a vertical layout toggling widgets visibility on click.

  6. The following user says thank you to Spitfire for this useful post:

    whitefurrows (2nd March 2012)

  7. #5
    Join Date
    May 2006
    Posts
    108
    Thanks
    35
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Subclassing QToolBox

    Thank you. Now have i create my own control that toggling widgets visibility on click. After i do that i have found a great example.

  8. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Subclassing QToolBox

    I am intrigued how this should work from a user's perspective. In your screenshot above you have two panels visible. When I click on Page 3 what should happen? Is the number of open panels limited to two? What happens if the panels + buttons will no longer fit in the available height?
    Last edited by ChrisW67; 2nd March 2012 at 22:39. Reason: spelling corrections

  9. #7
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Subclassing QToolBox

    Quote Originally Posted by ChrisW67 View Post
    I am intrigued how this should work from a user's perspective. In your screenshot above you have two panels visible. When I click on Page 3 what should happen? Is the number of open panels limited to two? What happens if the panels + buttons will no longer fit in the available height?
    If I were to implement such a thing, I would probably add a vertical scrollbar such that when the number of open panels exceeded the available vertical space, the contents could be scrolled. However, I would probably find the UI interaction annoying.

  10. #8
    Join Date
    May 2006
    Posts
    108
    Thanks
    35
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Subclassing QToolBox

    When I click on Page 3 what should happen?
    Page 3 is visible too.

    Is the number of open panels limited to two?
    No, every page can be visible.

    What happens if the panels + buttons will no longer fit in the available height?
    The contents could be scrolled.

    If you change setCurrentIndex() from the ToolBox example, the ToolBox can do all these things

    Qt Code:
    1. void ToolBox::setCurrentIndex(int index)
    2. {
    3. Page *c = page(index);
    4. if (!c){
    5. return;
    6. }
    7.  
    8. if (currentPage) {
    9. currentPage->button->setSelected(false);
    10. }
    11. c->button->setSelected(true);
    12.  
    13. if( c->sv->isVisible() ){
    14. c->sv->hide();
    15. }else{
    16. c->sv->show();
    17. }
    18.  
    19. currentPage = c;
    20.  
    21. updateTabs();
    22. emit currentChanged(index);
    23. }
    To copy to clipboard, switch view to plain text mode 

    Why should be the UI interaction annoying?

  11. #9
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Subclassing QToolBox

    QtDesigner uses similar widget to show available components and it's working fine.
    I can't see any problem with usability.

  12. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Subclassing QToolBox

    Quote Originally Posted by d_stranz View Post
    If I were to implement such a thing, I would probably add a vertical scrollbar such that when the number of open panels exceeded the available vertical space, the contents could be scrolled. However, I would probably find the UI interaction annoying.
    I would just use QwwTaskPanel

    Quote Originally Posted by Spitfire
    QtDesigner uses similar widget to show available components and it's working fine.
    I can't see any problem with usability.
    Designer uses a regular tree view. No need to reinvent the wheel.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  13. #11
    Join Date
    Mar 2015
    Posts
    1
    Qt products
    Qt5

    Default Re: Subclassing QToolBox

    Can someone share code how can i make the QToolbox with multiple openen widgets?

  14. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Subclassing QToolBox

    The toolbox, by definition, has only one widget open.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  15. #13
    Join Date
    Sep 2013
    Posts
    9
    Thanks
    1
    Qt products

    Default Re: Subclassing QToolBox

    Quote Originally Posted by whitefurrows View Post
    Page 3 is visible too.


    No, every page can be visible.


    The contents could be scrolled.

    If you change setCurrentIndex() from the ToolBox example, the ToolBox can do all these things

    Qt Code:
    1. void ToolBox::setCurrentIndex(int index)
    2. {
    3. Page *c = page(index);
    4. if (!c){
    5. return;
    6. }
    7.  
    8. if (currentPage) {
    9. currentPage->button->setSelected(false);
    10. }
    11. c->button->setSelected(true);
    12.  
    13. if( c->sv->isVisible() ){
    14. c->sv->hide();
    15. }else{
    16. c->sv->show();
    17. }
    18.  
    19. currentPage = c;
    20.  
    21. updateTabs();
    22. emit currentChanged(index);
    23. }
    To copy to clipboard, switch view to plain text mode 

    Why should be the UI interaction annoying?
    Hey

    Sorry for digging it up but would any1 mind converting it to PyQt4/5 maybe ? Tried to do it myself but failed badly :- (

    Regards

    Dariusz

Similar Threads

  1. Customizing QToolBox:tab
    By ialnik in forum Qt Programming
    Replies: 5
    Last Post: 5th February 2010, 17:12
  2. QToolBox
    By kavinsiva in forum Qt Programming
    Replies: 1
    Last Post: 11th August 2009, 06:19
  3. qtoolbox
    By mickey in forum Qt Programming
    Replies: 3
    Last Post: 1st June 2006, 17:27
  4. QToolBox
    By mickey in forum Newbie
    Replies: 4
    Last Post: 11th February 2006, 15:03
  5. QToolBox
    By mickey in forum Newbie
    Replies: 1
    Last Post: 9th February 2006, 21:21

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.