PDA

View Full Version : Subclassing QToolBox



whitefurrows
22nd February 2012, 15:44
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:


Q_D(QToolBox);
QToolBoxPrivate::Page *c = d->page(index);
if (!c || d->currentPage == c)
return;

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?

ChrisW67
23rd February 2012, 06:55
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.

whitefurrows
23rd February 2012, 08:12
I have attached a image to explain what i mean
7423
You understand and can help me?

Spitfire
23rd February 2012, 13:30
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.

whitefurrows
2nd March 2012, 13:59
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 (http://www.qtcentre.org/threads/81-QToolBox-Formatting).

ChrisW67
2nd March 2012, 23:38
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?

d_stranz
3rd March 2012, 23:01
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.

whitefurrows
4th March 2012, 02:14
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


void ToolBox::setCurrentIndex(int index)
{
Page *c = page(index);
if (!c){
return;
}

if (currentPage) {
currentPage->button->setSelected(false);
}
c->button->setSelected(true);

if( c->sv->isVisible() ){
c->sv->hide();
}else{
c->sv->show();
}

currentPage = c;

updateTabs();
emit currentChanged(index);
}

Why should be the UI interaction annoying?

Spitfire
5th March 2012, 12:02
QtDesigner uses similar widget to show available components and it's working fine.
I can't see any problem with usability.

wysota
5th March 2012, 12:24
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 (http://www.wysota.eu.org/wwwidgets/doc/html/qwwtaskpanel.html)


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.

gele
28th March 2015, 09:22
Can someone share code how can i make the QToolbox with multiple openen widgets?

wysota
28th March 2015, 09:27
The toolbox, by definition, has only one widget open.

Dariusz
30th October 2015, 21:18
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


void ToolBox::setCurrentIndex(int index)
{
Page *c = page(index);
if (!c){
return;
}

if (currentPage) {
currentPage->button->setSelected(false);
}
c->button->setSelected(true);

if( c->sv->isVisible() ){
c->sv->hide();
}else{
c->sv->show();
}

currentPage = c;

updateTabs();
emit currentChanged(index);
}

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