I am creating a GUI using Qt. I use stylesheets to change the positions of close-button and float-button to the left side of the titlebars of DockWidgets in Mac OS X. My code looks like this:
QString macOSXButtonStyle = "";
#ifdef MACOSX
macOSXButtonStyle = "QDockWidget::close-button, QDockWidget::float-button { subcontrol-position: left; } QDockWidget::close-button { left: 4px; } QDockWidget::float-button { left: 20px; }";
#endif
activeDockWidget->setStyleSheet(macOSXButtonStyle);
Repositioning does work. But the buttons appear smaller than before:
Before:
(source: cargath at www.informatik.uni-bremen.de)After:
(source: cargath at www.informatik.uni-bremen.de)I tried resizing them with different combinations of icon-size, size, width and height, but nothing seems to work. Any idea what's causing开发者_Go百科 the problem / how i could fix it?
Styling a default QDockWidget with your style doesn't seem to have any effect on icon size under Win 7 or Ubuntu 10.14, using Qt4.7.
Looking closely at the before and after pictures, the difference seems to be in height - the icons have the same baseline, and the toolbar is the same height. If explicitly changing the height hasn't worked, I wonder if some vertical padding might have been introduced somewhere? Is there any other Mac-specific styling in the app?
You could try explicitly setting padding: 0 in that style. Zero should be the default, so this many not change anything.
I was in the same situation, and I was able to restore the icons size by adding
QDockWidget
{
icon-size: 20px;
}
(Tested with both Qt 4.7 and Qt 4.8.)
精彩评论