─░brahim ─░brahim - 1 month ago 16
Android Question

Qt: Material Design is not running

I am using Qt 5.7. My OS is Ubuntu 16.04. My basic code is here:

import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.0

import QtQuick.Controls.Material 2.0

ApplicationWindow {
visible: true
width: 300
height: 300
title: qsTr("Hello World")

Material.theme: Material.Dark
Material.accent: Material.Green

Column {
anchors.centerIn: parent

RadioButton { text: qsTr("Radio Button 1") }
RadioButton { text: qsTr("Radio Button 2") }
RadioButton { text: qsTr("Radio Button 3") }
}
}


I use material design but when I ran this app on the desktop I see Qt default style, not material design: Image Link. I did not get any error or warning. When I ran this app on the Android Device (tablet) and Genymotion, I see same result. I am using NVIDIA card and my driver is X.Org (open source). But when I used NVIDIA 340.98 driver, I get this warning:
"NV-GLX" missing on display ":0"
and I see this app style is not material design on the desktop, Android device or Genymotion. How can I solve this problem? How can I use material design on Qt/QML?

Requirement results:

DRI_PRIME=1 glxinfo | grep OpenGL

dpkg -l | egrep "nvidia|bumblebee|nvidia-prime|fglrx"

Answer

Importing a style and setting attributes for it doesn't make the application run with that style. You can import multiple styles in the same file, to set style-specific attributes for each of them. Those take effect when the application is run with that specific style. See Using Styles in Qt Quick Controls 2 for the available methods to select a specific style.