Styling the QMdiArea using the the fusion style and QPalette (dark theme)
-
Hello, I am fairly new to Qt, please bear with me if my question sound dumb.
I've been playing around with the MdiExample from the MainWindow I changed the main function of the example to the following
int main(int argc, char *argv[]) { Q_INIT_RESOURCE(mdi); QApplication app(argc, argv); QApplication::setStyle(QStyleFactory::create("Fusion")); QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); QCoreApplication::setApplicationName("MDI Example"); QCoreApplication::setOrganizationName("QtProject"); QCoreApplication::setApplicationVersion(QT_VERSION_STR); QPalette darkPalette; darkPalette.setColor(QPalette::Window, QColor(53, 53, 53)); darkPalette.setColor(QPalette::WindowText, Qt::white); darkPalette.setColor(QPalette::Disabled, QPalette::WindowText, QColor(255, 127, 127)); darkPalette.setColor(QPalette::Text, QColor(86, 86, 86)); darkPalette.setColor(QPalette::Disabled, QPalette::Text, QColor(127, 127, 127)); darkPalette.setColor(QPalette::Dark, QColor(35, 35, 35)); darkPalette.setColor(QPalette::Shadow, QColor(20, 20, 20)); darkPalette.setColor(QPalette::Button, QColor(53, 53, 53)); darkPalette.setColor(QPalette::ButtonText, Qt::white); darkPalette.setColor(QPalette::Disabled, QPalette::ButtonText, QColor(127, 127, 127)); darkPalette.setColor(QPalette::BrightText, Qt::red); darkPalette.setColor(QPalette::Link, QColor(42, 130, 218)); darkPalette.setColor(QPalette::Highlight, QColor(86, 86, 86)); darkPalette.setColor(QPalette::Disabled, QPalette::Highlight, QColor(80, 80, 80)); darkPalette.setColor(QPalette::HighlightedText, Qt::black); darkPalette.setColor(QPalette::Disabled, QPalette::HighlightedText, QColor(127, 127, 127)); app.setPalette(darkPalette); QCommandLineParser parser; parser.setApplicationDescription("Qt MDI Example"); parser.addHelpOption(); parser.addVersionOption(); parser.addPositionalArgument("file", "The file to open."); parser.process(app); MainWindow mainWin; foreach (const QString &fileName, parser.positionalArguments()) mainWin.openFile(fileName); mainWin.show(); return app.exec(); }
It seems to work fairly well with the few problems:
- There seems to be a white line on the left edge of the SubWindow (picture attached) . The only way to I could get rid of that was setting the styleSheet and setting the border of to 0px
setStyleSheet("QMdiSubWindow { border: 0px solid #ffffff; }");
That for rid of the border altogether and the subWindow cannot be resized! So my question is how can I get rid of that line keeping the border or remove the border and add a QSizeGrip ?
2. The disabled button is showing a weird highlighted text which I am not able to change (picture attached). How do I fix that?Thanks in advance
-
@Gbhutra said in Styling the QMdiArea using the the fusion style and QPalette (dark theme):
- The disabled button is showing a weird highlighted text which I am not able to change (picture attached). How do I fix that?
Didn't try, but I guess you need to set the color for shadow in disabled state:
darkPalette.setColor(QPalette::Disabled, QPalette::Shadow, QColor(r, g, b));
-
@Gojir4 said in Styling the QMdiArea using the the fusion style and QPalette (dark theme):
darkPalette.setColor(QPalette::Disabled, QPalette::Shadow, QColor(r, g, b));
(Edited)
tried, but it didn't work. I suspect that underneath it's a QLabel with a raised text but I don't know how to set the color of those using QPalette