Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Styling the QMdiArea using the the fusion style and QPalette (dark theme)
Forum Updated to NodeBB v4.3 + New Features

Styling the QMdiArea using the the fusion style and QPalette (dark theme)

Scheduled Pinned Locked Moved Unsolved General and Desktop
qmdisubwindowqpalleteqstylesheetqstylefusion
3 Posts 2 Posters 1.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Gbhutra
    wrote on last edited by
    #1

    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:

    1. 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
    0_1561700282509_Screen Shot 2019-06-27 at 10.37.46 PM.png

    Gojir4G 1 Reply Last reply
    0
    • G Gbhutra

      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:

      1. 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
      0_1561700282509_Screen Shot 2019-06-27 at 10.37.46 PM.png

      Gojir4G Offline
      Gojir4G Offline
      Gojir4
      wrote on last edited by
      #2

      @Gbhutra said in Styling the QMdiArea using the the fusion style and QPalette (dark theme):

      1. 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));
      
      1 Reply Last reply
      0
      • G Offline
        G Offline
        Gbhutra
        wrote on last edited by Gbhutra
        #3

        @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

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved