Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Standard colors in QtCreator (KDE)
Forum Update on Monday, May 27th 2025

Standard colors in QtCreator (KDE)

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
kdeqtquickqmlarch linux
22 Posts 3 Posters 7.7k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on 2 Aug 2016, 13:07 last edited by
    #10

    Don't know how to do it from within a QML file but you can do it from C++:

    #include <QGuiApplication>
    #include <QQmlApplicationEngine>
    #include <QPalette>
    
    int main(int argc, char *argv[])
    {
        QGuiApplication app(argc, argv);
    
        QPalette systemPalette = QGuiApplication::palette();
        systemPalette.setColor(QPalette::Active, QPalette::Button, QColor("orange"));
        QGuiApplication::setPalette(systemPalette);
    
        QQmlApplicationEngine engine;
        engine.load(QUrl(QLatin1String("qrc:/main.qml")));
    
        return app.exec();
    }
    
    1 Reply Last reply
    1
    • R Offline
      R Offline
      Rouleaux
      wrote on 2 Aug 2016, 13:19 last edited by
      #11

      That code doesn't seem to change anything visually. Am I doing something wrong?

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on 2 Aug 2016, 13:22 last edited by
        #12

        It changes the system palette application wide, so the following will give you an orange rectangle:

            Rectangle {
                SystemPalette { id: systemPalette }
                anchors.fill: parent
                color: systemPalette.button
            }
        
        1 Reply Last reply
        0
        • R Offline
          R Offline
          Rouleaux
          wrote on 2 Aug 2016, 13:31 last edited by
          #13

          I'm not sure we are discussing the same thing haha. I'd like for my Qt Application to fetch the systempalette of the OS, and apply that to my application.

          ? 1 Reply Last reply 2 Aug 2016, 13:55
          0
          • V Offline
            V Offline
            Vicky Sharma
            wrote on 2 Aug 2016, 13:42 last edited by Vicky Sharma 8 Feb 2016, 13:42
            #14

            @Rouleaux
            I think there are some misunderstanding, it will be better if you post your code here so would be able to get that point on which this thread start and try to resolve too soon.

            1 Reply Last reply
            0
            • R Rouleaux
              2 Aug 2016, 13:31

              I'm not sure we are discussing the same thing haha. I'd like for my Qt Application to fetch the systempalette of the OS, and apply that to my application.

              ? Offline
              ? Offline
              A Former User
              wrote on 2 Aug 2016, 13:55 last edited by
              #15

              @Rouleaux Oh, I think I misunderstood your intentions completely. So your actually want all your controls to look natively?

              R 1 Reply Last reply 2 Aug 2016, 14:06
              0
              • R Offline
                R Offline
                Rouleaux
                wrote on 2 Aug 2016, 13:56 last edited by
                #16

                @Vicky-Sharma Yes, sorry, that might clear things up.

                import QtQuick 2.7
                import QtQuick.Window 2.2
                import QtQuick.Controls 2.0
                
                Window {
                    visible: true
                    width: 640
                    height: 480
                    title: qsTr("Hello World")
                
                    Button {
                        id: button1
                        x: 8
                        y: 8
                        text: qsTr("Nicotine Base")
                    }
                }
                
                

                This is my QML. I'd like to know wether there is an option to provide the systemtheme (mine for example is BreezeDark), but then applicationwide. Now I have to apply SystemPalette to every single element, but I suppose there must be an easier way right?

                1 Reply Last reply
                0
                • ? Offline
                  ? Offline
                  A Former User
                  wrote on 2 Aug 2016, 14:00 last edited by
                  #17

                  Ok, so for natively looking widgets you'll need

                  • QT += widgets in your *.pro file
                  • QApplication in main.cpp (not QGuiApplication)
                  • QtQuick.Controls 1 (not 2)

                  E.g.:

                  main.cpp

                  #include <QApplication>
                  #include <QQmlApplicationEngine>
                  
                  int main(int argc, char *argv[])
                  {
                      QApplication app(argc, argv);
                      QQmlApplicationEngine engine(QUrl(QLatin1String("qrc:/main.qml")));
                      return app.exec();
                  }
                  

                  main.qml

                  import QtQuick 2.7
                  import QtQuick.Controls 1.4
                  
                  ApplicationWindow {
                      visible: true
                      width: 640
                      height: 480
                      title: qsTr("Hello World")
                  
                      Button {
                          text: "Exit"
                          anchors.centerIn: parent
                          onClicked: Qt.quit()
                      }
                  }
                  
                  1 Reply Last reply
                  0
                  • ? A Former User
                    2 Aug 2016, 13:55

                    @Rouleaux Oh, I think I misunderstood your intentions completely. So your actually want all your controls to look natively?

                    R Offline
                    R Offline
                    Rouleaux
                    wrote on 2 Aug 2016, 14:06 last edited by Rouleaux 8 Feb 2016, 14:07
                    #18

                    @Wieland Shoot, I've just started using QtQuick.Controls 2.0..

                    ? 2 Replies Last reply 2 Aug 2016, 14:09
                    0
                    • V Offline
                      V Offline
                      Vicky Sharma
                      wrote on 2 Aug 2016, 14:07 last edited by
                      #19

                      @Rouleaux
                      unfortunately i don't have 5.7 but i checked on 5.6 and rewrite few thing, you may check too as well as "Wieland" is also post write one check and revert if any error.
                      import QtQuick 2.5
                      import QtQuick.Window 2.2
                      import QtQuick.Controls 1.4

                      Window {
                      visible: true
                      width: 640
                      height: 480
                      title: qsTr("Hello World")

                      Button {
                          id: button1
                          x: 8
                          y: 8
                          text: qsTr("Nicotine Base")
                      }
                      

                      }

                      1 Reply Last reply
                      0
                      • R Rouleaux
                        2 Aug 2016, 14:06

                        @Wieland Shoot, I've just started using QtQuick.Controls 2.0..

                        ? Offline
                        ? Offline
                        A Former User
                        wrote on 2 Aug 2016, 14:09 last edited by
                        #20

                        @Rouleaux I thought you were only complaining about the white button text, because, yes, it actually shouldn't use the system palette at all, unless you add support for native widgets as described above. sry! =)

                        1 Reply Last reply
                        0
                        • R Rouleaux
                          2 Aug 2016, 14:06

                          @Wieland Shoot, I've just started using QtQuick.Controls 2.0..

                          ? Offline
                          ? Offline
                          A Former User
                          wrote on 2 Aug 2016, 14:12 last edited by
                          #21

                          @Rouleaux said:

                          Shoot, I've just started using QtQuick.Controls 2.0..

                          No native widgets with Controls 2. You need to supply a custom style then (see your other thread).

                          1 Reply Last reply
                          0
                          • R Offline
                            R Offline
                            Rouleaux
                            wrote on 2 Aug 2016, 14:25 last edited by
                            #22

                            @Wieland I understand now. Thank you very much for your help!

                            1 Reply Last reply
                            0

                            19/22

                            2 Aug 2016, 14:07

                            • Login

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