1

Short version of question

How to apply defined in resource file QSS style to QWidget and QtQuick controls simultaneously?

Full version of question

There is some big project which is written using Qt. For customizing of appearance of controls is used Style Sheet defined in resource file. Now to the project added widget which use QtQuick control. By default control inherited from QWidget looks different with QtQuick controls. So question is: how to extend already existed StyleSheet on QtQuick controls with minimal changes of QtQuick code?

Example

Here is complete example for better describing of my question. The project has following structure:

.
├── CMakeLists.txt
├── main.cpp
├── MainWidget.cpp
├── MainWidget.h
├── QtWidget.cpp
├── QtWidget.h
├── QuickWidget.cpp
├── QuickWidget.h
└── resources
    ├── resources.qrc
    ├── style.qss
    └── widget.qml

MainWidget class defines (as expected) the main widget. At the begining MainWidget contains only one widget QtWidget which is inherited from QWidget. For customizing of appearance is used style sheet defined in resources/style.qss. Later QuickWidget class is added to the project. QuickWidget class v QtQuick control which is defined in file: resources/widget.qml. After building and launching application:

mkdir build
cd build
cmake ..
make
./qqcs

the following window will be displayed:

enter image description here

I'm using:

  • Qt 5.6;
  • KUbuntu 15.10;
  • Plasma Desctop.
1

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.