Main Toolbar/Toolbar in QToolBar

Àlex Fiestas afiestas at kde.org
Tue Aug 13 12:00:37 UTC 2013


So, last thing to discuss about "Make QToolBar follow KDE settings" is the 
differentiation we do between Main Toolbar and just Toolbar.

Effectively a Main Toolbar is usually a toolbar that is a child of QMainWindow 
while a "ToolBar" is a toolbar who's parent is another QWidget.

While Qt doesn't call them "Main Toolbar" it can differentiate them by:
QMainWindow::setButtonStyle and QMainWindow::setIconSize

So it seems that the way to go is make the differentiation in the Style, doing 
either of these two things:

QWidget *parent = qtoolbar->parentWidget();
if (qobject_cast<QMainWIndow*>(parent)) {
	return MainToolbar;
} else {
 	return Toolbar;
}

Some code like this should be in KStyle and oxygenstyle and all styles that 
are considered KDE (Note that the style plays an important role when 
integrating a platform in Qt, so we need K stuff in there)

or we can also try to add new stylehints:
-PM_MainWindowToolBarIconSize
-PH_MainWindow_ToolBar_buttonStyle
-PH_toolBar_buttonStyle

I think the second option (Adding stylehints) is the best one, these 
stylehints really make sense since Qt is already making the differentiation 
and allowing the developer to change those values by hand, so it only makes 
sense to allow the style to change those as well.

So, what do you think?

Cheers.




More information about the Kde-frameworks-devel mailing list