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. Dark mode doesn't work well in Qt 6.5
QtWS25 Last Chance

Dark mode doesn't work well in Qt 6.5

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 5 Posters 2.5k Views
  • 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.
  • L Offline
    L Offline
    lincoln
    wrote on 9 Apr 2023, 23:15 last edited by lincoln 4 Sept 2023, 23:19
    #1

    Hi guys, I have the following problem, I have two buttons, one to change my app to dark mode and another to go back to a light style, the problem I have is that the title bar stays with the previous color, and it only changes if another operation is done, my question is how can I make the title bar of the form also change color, along with the entire app, thanks in advance.

    Widget::Widget(QWidget *parent)
      : QWidget(parent), ui(new Ui::Widget), standarPalette{qApp->style()->standardPalette()}
    {
      ui->setupUi(this);
      
    
      QObject::connect(ui->pushButton, &QPushButton::clicked, this, [&](){
        
        qApp->setPalette(standarPalette);
      });
      QObject::connect(ui->pushButton_2, &QPushButton::clicked, this, [&](){
     
        QPalette mPalette;
    
          mPalette.setColor(QPalette::Window, QColor(53, 53, 53));
          mPalette.setColor(QPalette::WindowText, Qt::white);
          mPalette.setColor(QPalette::Base, QColor(25, 25, 25));
          mPalette.setColor(QPalette::AlternateBase, QColor(53, 53, 53));
          mPalette.setColor(QPalette::ToolTipBase, QColor(53, 53, 53));
          mPalette.setColor(QPalette::ToolTipText, Qt::white);
          mPalette.setColor(QPalette::Text, Qt::white);
          mPalette.setColor(QPalette::PlaceholderText,QColor(127,127,127));
          mPalette.setColor(QPalette::Button, QColor(53, 53, 53));
          mPalette.setColor(QPalette::ButtonText, Qt::white);
          mPalette.setColor(QPalette::BrightText, Qt::red);
          mPalette.setColor(QPalette::Link, QColor(42, 130, 218));
          mPalette.setColor(QPalette::Highlight, QColor(42, 130, 218));
          mPalette.setColor(QPalette::HighlightedText, Qt::black);
          mPalette.setColor(QPalette::Disabled, QPalette::Text, QColor(164, 166, 168));
          mPalette.setColor(QPalette::Disabled, QPalette::WindowText, QColor(164, 166, 168));
          mPalette.setColor(QPalette::Disabled, QPalette::ButtonText, QColor(164, 166, 168));
          mPalette.setColor(QPalette::Disabled, QPalette::HighlightedText, QColor(164, 166, 168));
          mPalette.setColor(QPalette::Disabled, QPalette::Base, QColor(68, 68, 68));
          mPalette.setColor(QPalette::Disabled, QPalette::Window, QColor(68, 68, 68));
          mPalette.setColor(QPalette::Disabled, QPalette::Highlight, QColor(68, 68, 68));
    
        qApp->setPalette(mPalette);
        qApp->setStyle("Fusion");
    
    
      });
    }
    
    Widget::~Widget()
    {
      delete ui;
    }
    
    
    
    #pragma once
    
    #include <QWidget>
    
    
    
    QT_BEGIN_NAMESPACE
    namespace Ui { class Widget; }
    QT_END_NAMESPACE
    
    class Widget : public QWidget
    
    {
      Q_OBJECT
    
    public:
      explicit Widget(QWidget *parent = nullptr);
      ~Widget();
    
    private:
      Ui::Widget *ui;
    
      const QPalette standarPalette{};
    };
    
    
    

    c38cd2c0-42bc-4f68-a20e-cd59a2c4934a-image.png

    84a7c7c7-985c-4de6-87f2-59af50cd2c11-image.png

    there you can see that the title bar stays with the previous color and changes after doing something else, such as changing the window or resizing the sale, or any other action and the colors when returning to light mode, are not the same as the default app had.

    Solitary wolf

    P R 2 Replies Last reply 9 Apr 2023, 23:22
    0
    • L lincoln
      9 Apr 2023, 23:15

      Hi guys, I have the following problem, I have two buttons, one to change my app to dark mode and another to go back to a light style, the problem I have is that the title bar stays with the previous color, and it only changes if another operation is done, my question is how can I make the title bar of the form also change color, along with the entire app, thanks in advance.

      Widget::Widget(QWidget *parent)
        : QWidget(parent), ui(new Ui::Widget), standarPalette{qApp->style()->standardPalette()}
      {
        ui->setupUi(this);
        
      
        QObject::connect(ui->pushButton, &QPushButton::clicked, this, [&](){
          
          qApp->setPalette(standarPalette);
        });
        QObject::connect(ui->pushButton_2, &QPushButton::clicked, this, [&](){
       
          QPalette mPalette;
      
            mPalette.setColor(QPalette::Window, QColor(53, 53, 53));
            mPalette.setColor(QPalette::WindowText, Qt::white);
            mPalette.setColor(QPalette::Base, QColor(25, 25, 25));
            mPalette.setColor(QPalette::AlternateBase, QColor(53, 53, 53));
            mPalette.setColor(QPalette::ToolTipBase, QColor(53, 53, 53));
            mPalette.setColor(QPalette::ToolTipText, Qt::white);
            mPalette.setColor(QPalette::Text, Qt::white);
            mPalette.setColor(QPalette::PlaceholderText,QColor(127,127,127));
            mPalette.setColor(QPalette::Button, QColor(53, 53, 53));
            mPalette.setColor(QPalette::ButtonText, Qt::white);
            mPalette.setColor(QPalette::BrightText, Qt::red);
            mPalette.setColor(QPalette::Link, QColor(42, 130, 218));
            mPalette.setColor(QPalette::Highlight, QColor(42, 130, 218));
            mPalette.setColor(QPalette::HighlightedText, Qt::black);
            mPalette.setColor(QPalette::Disabled, QPalette::Text, QColor(164, 166, 168));
            mPalette.setColor(QPalette::Disabled, QPalette::WindowText, QColor(164, 166, 168));
            mPalette.setColor(QPalette::Disabled, QPalette::ButtonText, QColor(164, 166, 168));
            mPalette.setColor(QPalette::Disabled, QPalette::HighlightedText, QColor(164, 166, 168));
            mPalette.setColor(QPalette::Disabled, QPalette::Base, QColor(68, 68, 68));
            mPalette.setColor(QPalette::Disabled, QPalette::Window, QColor(68, 68, 68));
            mPalette.setColor(QPalette::Disabled, QPalette::Highlight, QColor(68, 68, 68));
      
          qApp->setPalette(mPalette);
          qApp->setStyle("Fusion");
      
      
        });
      }
      
      Widget::~Widget()
      {
        delete ui;
      }
      
      
      
      #pragma once
      
      #include <QWidget>
      
      
      
      QT_BEGIN_NAMESPACE
      namespace Ui { class Widget; }
      QT_END_NAMESPACE
      
      class Widget : public QWidget
      
      {
        Q_OBJECT
      
      public:
        explicit Widget(QWidget *parent = nullptr);
        ~Widget();
      
      private:
        Ui::Widget *ui;
      
        const QPalette standarPalette{};
      };
      
      
      

      c38cd2c0-42bc-4f68-a20e-cd59a2c4934a-image.png

      84a7c7c7-985c-4de6-87f2-59af50cd2c11-image.png

      there you can see that the title bar stays with the previous color and changes after doing something else, such as changing the window or resizing the sale, or any other action and the colors when returning to light mode, are not the same as the default app had.

      P Offline
      P Offline
      Pl45m4
      wrote on 9 Apr 2023, 23:22 last edited by Pl45m4 4 Sept 2023, 23:25
      #2

      @lincoln said in Dark mode doesn't work well in Qt 6.5:

      only changes if another operation is done, my question is how can I make the title bar of the form also change color, along with the entire app, thanks in advance.

      What "other operation"? [Edit: Haven't seen the text below]

      such as changing the window or resizing

      I assume it's because you need a full repaint/render of your window to change the title bar. The button might only refresh the widget's content.


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      L 1 Reply Last reply 9 Apr 2023, 23:36
      0
      • L lincoln
        9 Apr 2023, 23:15

        Hi guys, I have the following problem, I have two buttons, one to change my app to dark mode and another to go back to a light style, the problem I have is that the title bar stays with the previous color, and it only changes if another operation is done, my question is how can I make the title bar of the form also change color, along with the entire app, thanks in advance.

        Widget::Widget(QWidget *parent)
          : QWidget(parent), ui(new Ui::Widget), standarPalette{qApp->style()->standardPalette()}
        {
          ui->setupUi(this);
          
        
          QObject::connect(ui->pushButton, &QPushButton::clicked, this, [&](){
            
            qApp->setPalette(standarPalette);
          });
          QObject::connect(ui->pushButton_2, &QPushButton::clicked, this, [&](){
         
            QPalette mPalette;
        
              mPalette.setColor(QPalette::Window, QColor(53, 53, 53));
              mPalette.setColor(QPalette::WindowText, Qt::white);
              mPalette.setColor(QPalette::Base, QColor(25, 25, 25));
              mPalette.setColor(QPalette::AlternateBase, QColor(53, 53, 53));
              mPalette.setColor(QPalette::ToolTipBase, QColor(53, 53, 53));
              mPalette.setColor(QPalette::ToolTipText, Qt::white);
              mPalette.setColor(QPalette::Text, Qt::white);
              mPalette.setColor(QPalette::PlaceholderText,QColor(127,127,127));
              mPalette.setColor(QPalette::Button, QColor(53, 53, 53));
              mPalette.setColor(QPalette::ButtonText, Qt::white);
              mPalette.setColor(QPalette::BrightText, Qt::red);
              mPalette.setColor(QPalette::Link, QColor(42, 130, 218));
              mPalette.setColor(QPalette::Highlight, QColor(42, 130, 218));
              mPalette.setColor(QPalette::HighlightedText, Qt::black);
              mPalette.setColor(QPalette::Disabled, QPalette::Text, QColor(164, 166, 168));
              mPalette.setColor(QPalette::Disabled, QPalette::WindowText, QColor(164, 166, 168));
              mPalette.setColor(QPalette::Disabled, QPalette::ButtonText, QColor(164, 166, 168));
              mPalette.setColor(QPalette::Disabled, QPalette::HighlightedText, QColor(164, 166, 168));
              mPalette.setColor(QPalette::Disabled, QPalette::Base, QColor(68, 68, 68));
              mPalette.setColor(QPalette::Disabled, QPalette::Window, QColor(68, 68, 68));
              mPalette.setColor(QPalette::Disabled, QPalette::Highlight, QColor(68, 68, 68));
        
            qApp->setPalette(mPalette);
            qApp->setStyle("Fusion");
        
        
          });
        }
        
        Widget::~Widget()
        {
          delete ui;
        }
        
        
        
        #pragma once
        
        #include <QWidget>
        
        
        
        QT_BEGIN_NAMESPACE
        namespace Ui { class Widget; }
        QT_END_NAMESPACE
        
        class Widget : public QWidget
        
        {
          Q_OBJECT
        
        public:
          explicit Widget(QWidget *parent = nullptr);
          ~Widget();
        
        private:
          Ui::Widget *ui;
        
          const QPalette standarPalette{};
        };
        
        
        

        c38cd2c0-42bc-4f68-a20e-cd59a2c4934a-image.png

        84a7c7c7-985c-4de6-87f2-59af50cd2c11-image.png

        there you can see that the title bar stays with the previous color and changes after doing something else, such as changing the window or resizing the sale, or any other action and the colors when returning to light mode, are not the same as the default app had.

        R Offline
        R Offline
        raoufM
        wrote on 9 Apr 2023, 23:26 last edited by
        #3

        @lincoln try this :

        Widget::Widget(QWidget *parent)
        : QWidget(parent), ui(new Ui::Widget), standarPalette{qApp->palette()}
        {
        ui->setupUi(this);

        QObject::connect(ui->pushButton, &QPushButton::clicked, this, &{
        qApp->setPalette(standarPalette);
        });

        QObject::connect(ui->pushButton_2, &QPushButton::clicked, this, &{
        QPalette mPalette;

        mPalette.setColor(QPalette::Window, QColor(53, 53, 53));
        mPalette.setColor(QPalette::WindowText, Qt::white);
        mPalette.setColor(QPalette::Base, QColor(25, 25, 25));
        mPalette.setColor(QPalette::AlternateBase, QColor(53, 53, 53));
        mPalette.setColor(QPalette::ToolTipBase, QColor(53, 53, 53));
        mPalette.setColor(QPalette::ToolTipText, Qt::white);
        mPalette.setColor(QPalette::Text, Qt::white);
        mPalette.setColor(QPalette::PlaceholderText,QColor(127,127,127));
        mPalette.setColor(QPalette::Button, QColor(53, 53, 53));
        mPalette.setColor(QPalette::ButtonText, Qt::white);
        mPalette.setColor(QPalette::BrightText, Qt::red);
        mPalette.setColor(QPalette::Link, QColor(42, 130, 218));
        mPalette.setColor(QPalette::Highlight, QColor(42, 130, 218));
        mPalette.setColor(QPalette::HighlightedText, Qt::black);
        mPalette.setColor(QPalette::Disabled, QPalette::Text, QColor(164, 166, 168));
        mPalette.setColor(QPalette::Disabled, QPalette::WindowText, QColor(164, 166, 168));
        mPalette.setColor(QPalette::Disabled, QPalette::ButtonText, QColor(164, 166, 168));
        mPalette.setColor(QPalette::Disabled, QPalette::HighlightedText, QColor(164, 166, 168));
        mPalette.setColor(QPalette::Disabled, QPalette::Base, QColor(68, 68, 68));
        mPalette.setColor(QPalette::Disabled, QPalette::Window, QColor(68, 68, 68));
        mPalette.setColor(QPalette::Disabled, QPalette::Highlight, QColor(68, 68, 68));
        
        qApp->setPalette(mPalette);
        qApp->setStyle("Fusion");
        

        });
        }

        In this modified code, I'm setting the initial standarPalette to qApp->palette() to ensure that the palette is initially set to the default system palette.

        Then, inside the dark mode button slot, I'm setting the QPalette::Window color to the same color as the QPalette::Base color. This should ensure that the title bar color changes along with the rest of the app.

        L 1 Reply Last reply 9 Apr 2023, 23:35
        0
        • R raoufM
          9 Apr 2023, 23:26

          @lincoln try this :

          Widget::Widget(QWidget *parent)
          : QWidget(parent), ui(new Ui::Widget), standarPalette{qApp->palette()}
          {
          ui->setupUi(this);

          QObject::connect(ui->pushButton, &QPushButton::clicked, this, &{
          qApp->setPalette(standarPalette);
          });

          QObject::connect(ui->pushButton_2, &QPushButton::clicked, this, &{
          QPalette mPalette;

          mPalette.setColor(QPalette::Window, QColor(53, 53, 53));
          mPalette.setColor(QPalette::WindowText, Qt::white);
          mPalette.setColor(QPalette::Base, QColor(25, 25, 25));
          mPalette.setColor(QPalette::AlternateBase, QColor(53, 53, 53));
          mPalette.setColor(QPalette::ToolTipBase, QColor(53, 53, 53));
          mPalette.setColor(QPalette::ToolTipText, Qt::white);
          mPalette.setColor(QPalette::Text, Qt::white);
          mPalette.setColor(QPalette::PlaceholderText,QColor(127,127,127));
          mPalette.setColor(QPalette::Button, QColor(53, 53, 53));
          mPalette.setColor(QPalette::ButtonText, Qt::white);
          mPalette.setColor(QPalette::BrightText, Qt::red);
          mPalette.setColor(QPalette::Link, QColor(42, 130, 218));
          mPalette.setColor(QPalette::Highlight, QColor(42, 130, 218));
          mPalette.setColor(QPalette::HighlightedText, Qt::black);
          mPalette.setColor(QPalette::Disabled, QPalette::Text, QColor(164, 166, 168));
          mPalette.setColor(QPalette::Disabled, QPalette::WindowText, QColor(164, 166, 168));
          mPalette.setColor(QPalette::Disabled, QPalette::ButtonText, QColor(164, 166, 168));
          mPalette.setColor(QPalette::Disabled, QPalette::HighlightedText, QColor(164, 166, 168));
          mPalette.setColor(QPalette::Disabled, QPalette::Base, QColor(68, 68, 68));
          mPalette.setColor(QPalette::Disabled, QPalette::Window, QColor(68, 68, 68));
          mPalette.setColor(QPalette::Disabled, QPalette::Highlight, QColor(68, 68, 68));
          
          qApp->setPalette(mPalette);
          qApp->setStyle("Fusion");
          

          });
          }

          In this modified code, I'm setting the initial standarPalette to qApp->palette() to ensure that the palette is initially set to the default system palette.

          Then, inside the dark mode button slot, I'm setting the QPalette::Window color to the same color as the QPalette::Base color. This should ensure that the title bar color changes along with the rest of the app.

          L Offline
          L Offline
          lincoln
          wrote on 9 Apr 2023, 23:35 last edited by
          #4

          @raoufM I made the change you said but it doesn't work, now I don't go back to light mode anymore.

          Solitary wolf

          R 1 Reply Last reply 9 Apr 2023, 23:42
          0
          • P Pl45m4
            9 Apr 2023, 23:22

            @lincoln said in Dark mode doesn't work well in Qt 6.5:

            only changes if another operation is done, my question is how can I make the title bar of the form also change color, along with the entire app, thanks in advance.

            What "other operation"? [Edit: Haven't seen the text below]

            such as changing the window or resizing

            I assume it's because you need a full repaint/render of your window to change the title bar. The button might only refresh the widget's content.

            L Offline
            L Offline
            lincoln
            wrote on 9 Apr 2023, 23:36 last edited by
            #5

            @Pl45m4 Could you show me some example or code of how to do it please.

            Solitary wolf

            P 1 Reply Last reply 9 Apr 2023, 23:44
            0
            • L lincoln
              9 Apr 2023, 23:35

              @raoufM I made the change you said but it doesn't work, now I don't go back to light mode anymore.

              R Offline
              R Offline
              raoufM
              wrote on 9 Apr 2023, 23:42 last edited by
              #6

              @lincoln said in Dark mode doesn't work well in Qt 6.5:

              I made the change you said but it doesn't work, now I don't go back to light mode anymore.

              I apologize for the confusion. I made a mistake in my previous response. Instead of QApplication::setPalette, you should use QWidget::setPalette to set the palette for your main widget. QApplication::setPalette sets the palette for the entire application, including windows and dialogs, whereas QWidget::setPalette sets the palette only for the widget that you call it on.

              try it now it should be executable :

              Widget::Widget(QWidget *parent)
              : QWidget(parent), ui(new Ui::Widget), standardPalette{qApp->palette()}
              {
              ui->setupUi(this);

              QObject::connect(ui->pushButton, &QPushButton::clicked, this, &{
              qApp->setPalette(standardPalette);
              });

              QObject::connect(ui->pushButton_2, &QPushButton::clicked, this, &{
              QPalette darkPalette;

              darkPalette.setColor(QPalette::Window, QColor(53, 53, 53));
              darkPalette.setColor(QPalette::WindowText, Qt::white);
              darkPalette.setColor(QPalette::Base, QColor(25, 25, 25));
              darkPalette.setColor(QPalette::AlternateBase, QColor(53, 53, 53));
              darkPalette.setColor(QPalette::ToolTipBase, QColor(53, 53, 53));
              darkPalette.setColor(QPalette::ToolTipText, Qt::white);
              darkPalette.setColor(QPalette::Text, Qt::white);
              darkPalette.setColor(QPalette::PlaceholderText,QColor(127,127,127));
              darkPalette.setColor(QPalette::Button, QColor(53, 53, 53));
              darkPalette.setColor(QPalette::ButtonText, Qt::white);
              darkPalette.setColor(QPalette::BrightText, Qt::red);
              darkPalette.setColor(QPalette::Link, QColor(42, 130, 218));
              darkPalette.setColor(QPalette::Highlight, QColor(42, 130, 218));
              darkPalette.setColor(QPalette::HighlightedText, Qt::black);
              darkPalette.setColor(QPalette::Disabled, QPalette::Text, QColor(164, 166, 168));
              darkPalette.setColor(QPalette::Disabled, QPalette::WindowText, QColor(164, 166, 168));
              darkPalette.setColor(QPalette::Disabled, QPalette::ButtonText, QColor(164, 166, 168));
              darkPalette.setColor(QPalette::Disabled, QPalette::HighlightedText, QColor(164, 166, 168));
              darkPalette.setColor(QPalette::Disabled, QPalette::Base, QColor(68, 68, 68));
              darkPalette.setColor(QPalette::Disabled, QPalette::Window, QColor(68, 68, 68));
              darkPalette.setColor(QPalette::Disabled, QPalette::Highlight, QColor(68, 68, 68));
              
              this->setPalette(darkPalette);
              qApp->setStyle("Fusion");
              

              });
              }

              Widget::~Widget()
              {
              delete ui;
              }

              L 1 Reply Last reply 9 Apr 2023, 23:54
              0
              • L lincoln
                9 Apr 2023, 23:36

                @Pl45m4 Could you show me some example or code of how to do it please.

                P Offline
                P Offline
                Pl45m4
                wrote on 9 Apr 2023, 23:44 last edited by
                #7

                @lincoln said in Dark mode doesn't work well in Qt 6.5:

                Could you show me some example or code of how to do it please.

                Try a call of update() or repaint() on your window/widget.

                // at the end of your lambda
                this->update();
                

                Or even do what is explained here.
                But: use it with care. Depending on your app / app design, "just" updating all windows/widgets at once can be a very resource consuming task. Esp. when calling it frequently.

                • https://doc.qt.io/qt-6/qapplication.html#allWidgets

                If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                ~E. W. Dijkstra

                L 1 Reply Last reply 9 Apr 2023, 23:53
                0
                • P Pl45m4
                  9 Apr 2023, 23:44

                  @lincoln said in Dark mode doesn't work well in Qt 6.5:

                  Could you show me some example or code of how to do it please.

                  Try a call of update() or repaint() on your window/widget.

                  // at the end of your lambda
                  this->update();
                  

                  Or even do what is explained here.
                  But: use it with care. Depending on your app / app design, "just" updating all windows/widgets at once can be a very resource consuming task. Esp. when calling it frequently.

                  • https://doc.qt.io/qt-6/qapplication.html#allWidgets
                  L Offline
                  L Offline
                  lincoln
                  wrote on 9 Apr 2023, 23:53 last edited by
                  #8

                  @Pl45m4 I already tried update() and repaint(), and nothing happens, anyway thanks for your answer.

                  Solitary wolf

                  1 Reply Last reply
                  0
                  • R raoufM
                    9 Apr 2023, 23:42

                    @lincoln said in Dark mode doesn't work well in Qt 6.5:

                    I made the change you said but it doesn't work, now I don't go back to light mode anymore.

                    I apologize for the confusion. I made a mistake in my previous response. Instead of QApplication::setPalette, you should use QWidget::setPalette to set the palette for your main widget. QApplication::setPalette sets the palette for the entire application, including windows and dialogs, whereas QWidget::setPalette sets the palette only for the widget that you call it on.

                    try it now it should be executable :

                    Widget::Widget(QWidget *parent)
                    : QWidget(parent), ui(new Ui::Widget), standardPalette{qApp->palette()}
                    {
                    ui->setupUi(this);

                    QObject::connect(ui->pushButton, &QPushButton::clicked, this, &{
                    qApp->setPalette(standardPalette);
                    });

                    QObject::connect(ui->pushButton_2, &QPushButton::clicked, this, &{
                    QPalette darkPalette;

                    darkPalette.setColor(QPalette::Window, QColor(53, 53, 53));
                    darkPalette.setColor(QPalette::WindowText, Qt::white);
                    darkPalette.setColor(QPalette::Base, QColor(25, 25, 25));
                    darkPalette.setColor(QPalette::AlternateBase, QColor(53, 53, 53));
                    darkPalette.setColor(QPalette::ToolTipBase, QColor(53, 53, 53));
                    darkPalette.setColor(QPalette::ToolTipText, Qt::white);
                    darkPalette.setColor(QPalette::Text, Qt::white);
                    darkPalette.setColor(QPalette::PlaceholderText,QColor(127,127,127));
                    darkPalette.setColor(QPalette::Button, QColor(53, 53, 53));
                    darkPalette.setColor(QPalette::ButtonText, Qt::white);
                    darkPalette.setColor(QPalette::BrightText, Qt::red);
                    darkPalette.setColor(QPalette::Link, QColor(42, 130, 218));
                    darkPalette.setColor(QPalette::Highlight, QColor(42, 130, 218));
                    darkPalette.setColor(QPalette::HighlightedText, Qt::black);
                    darkPalette.setColor(QPalette::Disabled, QPalette::Text, QColor(164, 166, 168));
                    darkPalette.setColor(QPalette::Disabled, QPalette::WindowText, QColor(164, 166, 168));
                    darkPalette.setColor(QPalette::Disabled, QPalette::ButtonText, QColor(164, 166, 168));
                    darkPalette.setColor(QPalette::Disabled, QPalette::HighlightedText, QColor(164, 166, 168));
                    darkPalette.setColor(QPalette::Disabled, QPalette::Base, QColor(68, 68, 68));
                    darkPalette.setColor(QPalette::Disabled, QPalette::Window, QColor(68, 68, 68));
                    darkPalette.setColor(QPalette::Disabled, QPalette::Highlight, QColor(68, 68, 68));
                    
                    this->setPalette(darkPalette);
                    qApp->setStyle("Fusion");
                    

                    });
                    }

                    Widget::~Widget()
                    {
                    delete ui;
                    }

                    L Offline
                    L Offline
                    lincoln
                    wrote on 9 Apr 2023, 23:54 last edited by
                    #9

                    @raoufM It remains the same, the title bar does not change, well thanks for your answer.

                    Solitary wolf

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      SimonSchroeder
                      wrote on 20 Apr 2023, 14:05 last edited by
                      #10

                      A widget is only the underlying Qt representation without the window decoration (at least on some platforms). Try to get the underlying window first and update the window instead of just the widget.

                      L 1 Reply Last reply 23 Apr 2023, 20:03
                      1
                      • S SimonSchroeder
                        20 Apr 2023, 14:05

                        A widget is only the underlying Qt representation without the window decoration (at least on some platforms). Try to get the underlying window first and update the window instead of just the widget.

                        L Offline
                        L Offline
                        lincoln
                        wrote on 23 Apr 2023, 20:03 last edited by
                        #11

                        @SimonSchroeder
                        Well, I don't understand what you mean by underlying window, and I have no idea how to do it, but thanks for your answer.

                        Solitary wolf

                        S 1 Reply Last reply 24 Apr 2023, 07:12
                        0
                        • C Offline
                          C Offline
                          CPPUIX
                          wrote on 24 Apr 2023, 02:50 last edited by
                          #12

                          See this for more information about what @SimonSchroeder mentioned.

                          1 Reply Last reply
                          0
                          • L lincoln
                            23 Apr 2023, 20:03

                            @SimonSchroeder
                            Well, I don't understand what you mean by underlying window, and I have no idea how to do it, but thanks for your answer.

                            S Offline
                            S Offline
                            SimonSchroeder
                            wrote on 24 Apr 2023, 07:12 last edited by
                            #13

                            @lincoln said in Dark mode doesn't work well in Qt 6.5:

                            Well, I don't understand what you mean by underlying window, and I have no idea how to do it, but thanks for your answer.

                            Qt has both QWidget and QWindow. The underlying operating system only knows about windows. However, creating each button, etc. as a window through the OS would be very slow. That is why Qt has a soft layer on top to quickly generate widgets instead of OS windows. The top level widgets still need to be windows.

                            Use https://doc.qt.io/qt-6/qwidget.html#windowHandle to get the underlying window if available. There, you can call requestUpdate().

                            L 1 Reply Last reply 26 Apr 2023, 02:43
                            0
                            • S SimonSchroeder
                              24 Apr 2023, 07:12

                              @lincoln said in Dark mode doesn't work well in Qt 6.5:

                              Well, I don't understand what you mean by underlying window, and I have no idea how to do it, but thanks for your answer.

                              Qt has both QWidget and QWindow. The underlying operating system only knows about windows. However, creating each button, etc. as a window through the OS would be very slow. That is why Qt has a soft layer on top to quickly generate widgets instead of OS windows. The top level widgets still need to be windows.

                              Use https://doc.qt.io/qt-6/qwidget.html#windowHandle to get the underlying window if available. There, you can call requestUpdate().

                              L Offline
                              L Offline
                              lincoln
                              wrote on 26 Apr 2023, 02:43 last edited by
                              #14

                              @SimonSchroeder Hello friend, I tried to do what you mention, but when querying this->windowHandle();
                              the result is always a nullptr.

                              Solitary wolf

                              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