How to make Qt icon (in menu bar and tool bar) larger? - qt

I think the default size is too small. Any way to change it? Thanks.

QToolbar has iconSize property.
As far as I know, the only way to change QMenu icon size is to create a custom style for it. You can read about it here

Related

QToolButton Space Between Text and Icon

I have a QToolButton. I wanted text and icon to be on it. I set button style by setToolButtonStyle(Qt::ToolButtonTextBesideIcon).
But icon and text are so close to each other. Is there a method to give some space between icon and text by css?
You can't. There is no such a property neither for QToolButton (nor for QPushButton). All the properties for these buttons are in the documentation.
One thing you can do is to create your own class inheriting from QToolButton and overriding the paintEvent(). In this function, you will manually place your icon.
This is the shortest solution, but if you're brave enough, there are longer paths, like creating your own button subclassing directly QWidget (but in this case, you will need to implement ALL its behavior).
You can achieve it although this is not the documented solution.
Just provide spaces in QPushButton text start. By Doing this, icon and text will automatically go far from each other.

QT Tab bar's top highlight with stylesheet

I have a problem when trying to change the color of QTabBar's top line (blue line in the picture below).
Is this a separate part of tabBar (like scroller or tear) or its top border ? And how can I change its color with styleSheet and leave the other parts of tabBar unchanged?
P.S. : My tabBar::styleSheet returns an empty string, so I can't get current style and make changes in it.
If you're using a "system" style, you may not be able to change the color of the line (cause representation of UI elements is not handled by Qt but by the system).
You should define a complete style for QTabBar (and maybe QTabWidget too) that you can customize as you wish.
See the Qt Style Sheets Examples page.
Problem solved:
setStyleSheet("QTabBar::tab:selected { selection-background-color: red; }");

How can I make a QMenuBar item appear over its QMenu

First of all, I'm fairly new with Qt and Qt Creator so go easy if this is a stupid question.
I was practicing using Qt Creator, playing around with css styles. In particular, I'm trying to get the menubar and its menus to look something like this (on Windows): http://i.stack.imgur.com/9lMnQ.png.
However, the closest I've been able to get so far is this: http://i.stack.imgur.com/5Nlen.png.
I've searched online to see if anyone has tried something like this but I wasn't able to find anything.
The only possible solution I can think of is if the menubar item (with no bottom border) could be rendered in above the menu, so that they overlap, covering its top border over the width that they overlap.
If that won't work or is impossible or whatever please do suggest any other solutions/workarounds/hacks.
Thanks in advance!
I think that the only good solution is to avoid any tricks and create a new widget:
Create a new class inherited from QWidget with Qt::Popup attribute.
Place a QMenu into a layout of the widget.
Get a position of QMenuBar item which is clicked using QMenuBar::getActionGeometry.
Calculate position of the widget and of the tab in the widget to be placed over the menubar item.
Customize form of the widget using QWidget::setMask to make it look like a rectangle with a tab.
Show your widget instead of QMenu.

Subclassing QMessageBox

I need to customize QMessageBox. I need to remove the frame and title bar and add my own title bar and close button. Also need to replace the standard buttons and probably redo the background color of the box.
Is it possible to subclass it and achieve the above? is there any example anywhere for this? Or, should I just subclass Dialog and create my own message box?
This tutorial on custom windows might help you. It's in French but the code examples are in English, it shows how to compose your own title bar, create a window and attach the new title bar on it. I've been through it before, it's pretty straightforward once you've done it.
There is no need to subclass QMessageBox or QDialog. You can pass a QMessageBox the parameter Qt::FramelessWindowHint to remove the frame and buttons. You can also use Qt Style Sheets to style the background of the QMessageBox as well as the buttons. Something like this should work:
msgBox->setStyleSheet("QDialog {background-color: red;}"
"QPushButton {background-color: blue;}")
I haven't tested this but it should work or be pretty close.

Flex: Skinning menuBar - is it possible?

I wish to skin MenuBar, and change it's itemSkin to something else, like different background color for each menu item.
Is it possible ?
I found the solution
the main idea is to create a class overriding MenuBarItem.
Then - about the background - i have create one Image to store the color, and i switched it's position with the label of the menu item.
So far it is sufficiently good solution. :)

Resources