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. qtquickcontrols2.conf doesn't apply all settings
Forum Updated to NodeBB v4.3 + New Features

qtquickcontrols2.conf doesn't apply all settings

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 2 Posters 2.6k Views 2 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.
  • M Offline
    M Offline
    Mark81
    wrote on last edited by
    #1

    I'm trying to use the qtquickcontrols2.conf to define the global settings of my QML application.
    Here my main.cpp file:

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

    Main.qml

    import QtQuick 2.9
    import QtQuick.Layouts 1.3
    import QtQuick.Controls 2.2
    import QtQuick.Controls.Material 2.2
    
    ApplicationWindow {
        visible: true
        width: 1280
        height: 800
    
        Page {
            anchors.fill: parent
            header:
                TabBar {
                    id: bar
    
                    TabButton {
                        text: qsTr("A")
                    }
    
                    TabButton {
                        text: qsTr("B")
                    }
    
                    TabButton {
                        text: qsTr("C")
                    }
                }
    
            SwipeView {
                currentIndex: bar.currentIndex
                anchors.fill: parent
    
                Pane {
                    Text {
                        text: qsTr("1")
                    }
                }
    
                Pane {
                    Text {
                        text: qsTr("2")
                    }
    
                }
    
                Pane {
                    Text {
                        text: qsTr("3")
                    }
                }
            }
        }
    }
    

    qtquickcontrols2.conf added in the resources file:

    [Controls]
    Style=Material
    
    [Material]
    Theme=Dark
    Accent=Purple
    Primary=BlueGrey
    
    [Material\Font]
    PixelSize=50
    

    It actually applies only the Material 'Accent' properties. But neither 'Theme' nor 'PixelSize' properties are applied.
    I'm running Qt5.9.1 under Windows 7 and to be sure whether they are supported I tried to put them inside my ApplicationWindow and they worked.

    It's the first time I wrote such a config file: is there any error in it?

    1 Reply Last reply
    0
    • jpnurmiJ Offline
      jpnurmiJ Offline
      jpnurmi
      wrote on last edited by
      #2
      • If I remember correctly, ToolBar is the only control that uses the Primary color. Not sure where you expect it to show up. :)
      • Theme should work. Does the app run with the Material style at least, indicating that the .conf file is actually loaded?
      • Support for specifying the default font in qtquickcontrols2.conf was added in Qt 5.10.
      1 Reply Last reply
      1
      • M Offline
        M Offline
        Mark81
        wrote on last edited by
        #3

        I've just updated to Qt 5.10.1 but:

        • default font doesn't work, I had to use the old way:
            auto font = app.font();
            QFontInfo fi(font.defaultFamily());
            font.setPixelSize(50);
            app.setFont(font);
        
        • the Material theme is loaded but only partially: the Theme is not applied. Even if I set the Dark one it's still show the Light (or default?). Instead the Accent is working. I'm not talking about the Primary at all because I didn't know where it's used :)
        1 Reply Last reply
        0
        • jpnurmiJ Offline
          jpnurmiJ Offline
          jpnurmi
          wrote on last edited by jpnurmi
          #4

          But you get a dark background, right? Notice that the QML Text type is part of Qt Quick (core), meaning that it is not aware of the Qt Quick Controls 2 module. You may use the QML Label type to get a styled text label for Qt Quick Controls 2. What comes to the default font via qtquickcontrols2.conf, strange, because it works fine for me with 5.10.1. Did you run with the correct Qt Version (Kit)? :)

          0_1523280981440_font.png

          1 Reply Last reply
          1
          • M Offline
            M Offline
            Mark81
            wrote on last edited by
            #5

            I didn't aware of that. I will try with the Label Component.
            But I get a white background! Only the accent works from qtquickcontrols2.conf as said.

            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