alirezabe
alirezabe

Reputation: 63

how can change tittleBar button like close and minimize button in Qt QWidget

i want to change style of QWidget tittleBar button like close and minimize in windows but there is no similar stylesheet elements. i am using Qt5.1 and windows7.

can any body help me?

Upvotes: 4

Views: 441

Answers (2)

László Papp
László Papp

Reputation: 53155

You can set the window icon on your widget as per documentation with the following property:

windowIcon : QIcon

This property holds the widget's icon.

This property only makes sense for windows. If no icon has been set, windowIcon() returns the application icon (QApplication::windowIcon()).

So, your code would look like something like this:

myWidget->setWindowIcon("/path/to/your/icon/file");

The icon file path can be relative and absolute as well as one coming from the resource system. The easiest way to test it quickly is just to use the absolute path, but if you plan to ship assets with your application to be self-contained, then you can use resource file with the resource system.

Upvotes: 0

Abhishek Bansal
Abhishek Bansal

Reputation: 12715

If you are talking about how to do this windows, you can do:

this->setWindowIcon(QIcon(":myiconfile.png"));

You will have to add the file in your resources.

Upvotes: 1

Related Questions