Reputation: 555
I want to know is it possible to make application fully skinned/styled in Qt I mean by that not only controls inside the application window but the mainwindow itself! like close button/maximize button/minimize button and the bar, and the mainwindow border!, is it possible to do that in Qt? and how to?
Upvotes: 2
Views: 1805
Reputation: 1572
The second argument to the QWidget
constructor is Qt::WindowFlags
. You can use the flags to control the properties of a window. For example, pass the flag Qt::FramelessWindowHint
to create a borderless window.
There are a few ways to do this in code. You can use the setWindowsFlag
method from within your widgets constructor:
setWindowFlags(Qt::FramelessWindowHint);
If you are creating a custom widget, you can pass the flag to QWidget's
constructor:
YourWidget::YourWidget(QWidget *parent) : QWidget(parent, Qt::FramelessWindowHint)
{
// ....
}
Or you can pass the flag when you create a widget:
QWidget *your_widget = new QWidget(parent, Qt::FramelessWindowHint);
There are also flags for the minimize button (Qt::WindowMinimizeButtonHint
), maximize button (Qt::WindowMaximizeButtonHint
), close button (Qt::WindowCloseButtonHint
), and title bar (Qt::WindowTitleHint
). With these flags, you must also set Qt::CustomizeWindowHint
to disable the defaults as described in the documentation.
See the flags documentation for a full list and additional details.
As @Merlin069 stated, style sheets allow you to control the look and feel of the widgets within your application.
Upvotes: 1
Reputation: 27621
Yes it is possible. The best method in Qt is to use Qt style sheets. The Qt documentation has plenty of examples and you can style all the widgets, either by specifying a whole class such as QPushButton, or a single, named widget.
As for the items on the title bar, I'm not sure if that's possible directly, but you could certainly turn off the main tool bar that contains the minimise / maximise buttons and then implement and style your own widgets while replicating their functionality.
Upvotes: 2