I encounter many difficulties while I try to set my Button background following the documention.
For some reason Qt doesn't find the import QtQuick.Controls.Styles. I've tried to import it in many ways but without success. My last try:
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import QtGraphicalEffects 1.0
Button {
id: btn
property int row
property int col
property Item buttonPreview
property bool hasPreview: true
GridLayout.row: row
GridLayout.col: col
GridLayout.colSpan: 2
GridLayout.rowSpan: 2
width: 50
height: 50
style: ButtonStyle {
background: Rectangle {
color:"white"
}
}
...
}
I encounter the following errors:
import QtQuick.Controls.Styles 1.2code is underlined saying thatQML module not foundBtn.qml:21:5: Cannot assign to non-existent property "style"appears when I am using the application.
Strange thing that if I remove the import QtQuick.Controls.Styles 1.2, the style: ButtonStyle { becomes underlined.
I use Qt 5.3.2.
Part of my .pro configuration file:
QT += core gui svg xml network quick gui-private qml quickwidgets widgets concurrent
TARGET = ProjectName
TEMPLATE = app
CONFIG += c++12 plugin
Any idea is appreciated, really thanks for the time for helping solving my problem.
<qtdir>/qml/QtQuick/Controls/Styles? - Mitchqml\QtQuick\Controls\Styles: Base, Desktop directories and qmldir file. - flatronkaCONFIG += c++12must beCONFIG += c++11. - Simon Warta