Customizing a dialogs background with QStyle
Hello,
is there any way to customize the painting of a QDialog? I would like to define a gradient as background and a custom painted frame. I can define this in a stylesheet, but I have to do it in my own QStyle implementation.
Kind regards,
Sebastian
Re: Customizing a dialogs background with QStyle
Quote:
Originally Posted by
SebastianBecker
Hello,
is there any way to customize the painting of a QDialog? I would like to define a gradient as background and a custom painted frame. I can define this in a stylesheet, but I have to do it in my own QStyle implementation.
Kind regards,
Sebastian
You can easily do it using style sheet. Just set the "background" property of QDialog. And set the brush style Qt::RadialGradientPattern.
For more info click here.
Re: Customizing a dialogs background with QStyle
Alright, i know that I can do this by using a stylesheet. But how can I do that WITHOUT stylesheets. They are not an option for me since there are some constraints on the project... (Stylesheets take a while for parsing and initialization...)
Kind regards,
Sebastian
Re: Customizing a dialogs background with QStyle
Take a look here.
http://doc.trolltech.com/4.5/widgets-styles.html
In This example the custom style class inherited by QMotifStyle. You can derive your style class by QWindowsStyle or any inbuilt style class depending on your basic requirement.
Re: Customizing a dialogs background with QStyle
Use QPalette instead.
Code:
gradient.setColorAt(0, Qt::black);
gradient.setColorAt(1, Qt::white);
palette.
setBrush(QPalette::Window, brush
);
dialog.setPalette(palette);
Re: Customizing a dialogs background with QStyle
Quote:
Originally Posted by
Giga
1. The title of this post says that he want to use QStyle.
Quote:
Customizing a dialogs background with QStyle
2. Qt Docs says:
Quote:
For example, the following style sheet specifies that all QLineEdits should use yellow as their background color, and all QCheckBoxes should use red as the text color:
QLineEdit { background: yellow }
QCheckBox { color: red }
For this kind of customization, style sheets are much more powerful than QPalette.