Problems with Open-Source Downloads read https://www.qt.io/blog/problem-with-open-source-downloads and https://forum.qt.io/post/638946

Custom style isn't applied



  • Hello. I've read about Creating a Custom Style and about Using Styles in Qt Quick Controls. Also, I've used this Flat Style example as practical example of how and what to do.

    So, seems like I've done everything according to the official documentation, but unfortunately I'm not able to make my application to use the custom style I've created. Maybe I end up doing something wrong or misunderstood something? Could you, please, take a look?

    My custom style MyStyle consists of a single file Text.qml (just for a testing purposes for now):

    import QtQuick.Templates 2.15 as T
    
    T.Text {
      font.pointSize: 32
      color: "white"
    }
    

    QtCreator doesn't like this code for some reason:
    Screenshot_2.png
    I also tried to add "import QtQuick 2.15" line, it doesn't change anything.

    MyStyle directory is in the project root. Text.qml is in a resource file qml.qrc (which contains other .qml project files):
    Screenshot_3.png
    I've tried two different approaches to using the style. First, adding qtquickcontrols2.conf file (into qml.qrc) with the following content:

    [Controls]
    Style=MyStyle
    

    Second, using setStyle call before loading main window component via QQmlApplicationEngine:

    QQuickStyle::setStyle(":/MyStyle");
    

    Neither of these two works. Building and running the project doesn't give any errors. So, I can't understand what the problem is. The style just isn't applied - Text component doesn't use my font size and color.

    My version of Qt is 5.15.1 (mingw 8.1 32bit). and QtCreator is:
    Qt Creator 4.13.2
    Based on Qt 5.15.1 (MSVC 2019, 64 bit)
    Built on Oct 1 2020 01:14:56

    Thank you in advance.