Qt Gui Application background color stylesheet
-
Hi AcidLys,
have you read this link. It is very useful. It explains how to use stylesheet.
http://qt-project.org/doc/qt-4.8/stylesheet-syntax.html
If you like to use a stylesheet file for the whole app, then you have to load it in your main.cpp.
Checkout QApplication::setStylesheet();
-
For more information on StyleSheets you can check
"Qt Style Sheets Reference":http://qt-project.org/doc/qt-4.8/stylesheet-reference.html#list-of-properties
"Qt Style Sheets Examples":http://doc-snapshot.qt-project.org/4.8/stylesheet-examples.html
also in order to set the stylesheet for the whole application you can try the following code:
@QFile styleSheet(":/Stylesheet/yourStylesheet.qss"); //path where the file is stored
if (!styleSheet.open(QIODevice::ReadOnly)
{
qWarning("Unable to open ::/Stylesheet/yourStylesheet.qss");
return;
}
qApp->setStyleSheet(styleSheet.readAll());@ -
This does not help in case of message box or a custom widget which i don't know how to be done. I searched the internet before i ask. In case you know, please reply, otherwise no problem.
-
Hi SherifOmran,
do you try to hitchhike this tread?
In the first mail messageBox was not mentioned and it was send by another author.Here, is what you are looking for, I got it from the qt documentations:
@*[environment="##ENV"] QMessageBox{
background-color: ##INACTIVE;
border: 3px solid ##EXTRA_DARK;
}*[environment="##ENV"] QMessageBox QPushButton{
border-radius: 8px;
icon-size: 28px;
min-height: 42px;
max-height: 42px;
min-width: 50px;
background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 ##NORMAL, stop: 0.1 ##INACTIVE, stop:0.15 ##NORMAL, stop:0.9 ##NORMAL, stop:1 ##EXTRA_DARK);
border: 0px solid none;
border-right: 2px solid ##NORMAL;
border-left: 2px solid ##NORMAL;
}*[environment="##ENV"] QMessageBox QPushButton:pressed,
*[environment="##ENV"] QMessageBox QPushButton:checked{
background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 ##EXTRA_DARK, stop: 0.1 ##PRESSED, stop:0.8 ##PRESSED, stop:0.9 ##NORMAL, stop:1 ##PRESSED);
border: 2px solid ##PRESSED;
}@ -
[quote author="messi" date="1346654781"]Hi SherifOmran,
do you try to hitchhike this tread?
In the first mail messageBox was not mentioned and it was send by another author.[/quote]
The actual discussion for the message box was going "on this thread":http://qt-project.org/forums/viewthread/20041/ so for the implementation I directed him here, not his fault :)
Thanks for the code messi :)
-
-
Oh, I am sorry, did nt realize it is another thread.
-
If I am allowed to ask. What does *[environment="##ENV"] mean? and what should I put instead of #ENV?
I don't find it in the documentation. Any link?
-
The code is quite complicated and it would need a long explanation.
Remove all *[environment="##ENV"] and replace all words with ## with color value.For more info please checkout the following links.
http://qt-project.org/doc/qt-4.8/stylesheet-syntax.html
http://qt-project.org/doc/qt-4.8/stylesheet-customizing.html