Is there any way to apply stylesheets to QQuickWidget's QML object
-
I'm trying to do this:
QQuickWidget* widget = new QQuickWidget(this); widget->setSource(QUrl("qrc:/qml/1.qml")); widget->setStyleSheet("background:red"); widget->show();
But style sheet is not working on QML object.
-
Hi,
The AQt-StyleSheets project is likely what you are looking for.
-
So there is nothing about any native method, right?
-
What do you mean by native method ?
-
E.g. you can set a stylesheet to a regular Qt widget just like this:
// For example on QPushButton QPushButton* myButton = new QPushButton(this); myButton->setStyleSheet(“color:white; background:url(“C:\my_pic.png”);”);
But why i can't do the same thing on QML widgets natively. Is there a different tech behind regular Qt widgets and QML widgets. Or Has The Qt Company offer a native way to do the same thing on the QML things.
Meanwhile thanks for your supports.
-
Well, there's no such thing as QML widgets. That's not the same technology at all.
QtQuick 1 was based on the Graphics View framework but QtQuick 2 is a completely different beast and doesn't share anything with the widget world.
-
But if you want to set stylesheet for button or rectangle than use
style: ButtonStyle{
color: "red" or etc which you want.
} -
I got it, I will looking for other ways. Thanks again.
-
@Vicky-Sharma That's rather "inline" styling of each element which is not the same as having a Qt style sheet like for the widgets module.