qqmlcomponent

Load a qml component from another qml file dynamically and access that component's qml type properties

巧了我就是萌 提交于 2020-01-07 05:28:07
问题 I looked into other questions regarding this topic in StackOverflow but it did not help me. I am new to QML/Javascript and I went through QML docs regarding this question but it did not help. Below is one file 'SmallWindow.qml' Item { ... property var statusColour: calStatusColour(() property Component devViewNameComponent: devNameComp function calStatusColour() { var color = "black" //Here, colour will be changed based on some status. } Row { Component{ id:devNameComp Rectangle { id

How to hide a QML Window when opening a other QML Window

喜夏-厌秋 提交于 2020-01-05 02:57:42
问题 I need to hide The QML Window when opening the another QML Window while clicking the button,I use Loader to open the another QML Window and its only hide the QML form components not QML Window,but I currently use window component to opens the QML Window Here is my code : Button { id: button2 x: 19 y: 54 width: 114 height: 25 text: qsTr("DIFF-R") style: ButtonStyle { background: Rectangle { implicitWidth: 10 implicitHeight: 25 border.width: control.activeFocus ? 2 : 1 border.color: "#555"

Access Listview currentIndex from Delegate

*爱你&永不变心* 提交于 2019-12-31 18:00:43
问题 I have a QML ListView where the delegate loads it's component from another file. When clicking on an delegate item, I want to update ListView . CurrentIndex and highlight the selected item. It works, when I explicitly set the id of the ListView . However since I want to use the delegate's Component also for other ListView s, I'm stuggeling to find a generic way how to access ListView.currentIndex from within a delegate Component . Here is the Code: main.qml import QtQuick 2.4 import QtQuick

Set GridView model property from C++ without setting Context

断了今生、忘了曾经 提交于 2019-12-25 04:27:18
问题 I'm trying to set the model property of a QML GridView from C++ by calling QQmlProperty::write(gridview, "model", QVariant::fromValue(objlist)); . gridview is set correctly, I can modify the property from C++, when I set it to a QList with 6 entries and print them from QML I get qml: model = item(0x30617b50), Item(0x30617b90), Item(0x30617bd0), Item(0x30617c10), Item(0x30617c50), Item(0x30617cd0) , though the model is not being displayed. The Qt documentation suggest calling QQmlContext *ctxt

How to create a new QQuickItem copy from scratch on C++ side with the same properties as an existing one

跟風遠走 提交于 2019-12-24 18:29:17
问题 I have a QQuickItem fetched from C++ side like this. QQuickItem * my_item = qmlEngine->rootObjects()[0]->findChild<QQuickItem*>("ItemObjectName"); my_item is valid & has all the properties set on to it. Scenario I have 2 windows which need this QQuickItem to be drawn on alterantively. I want to render this my_item to a different window. This works perfectly fine as long as I set the Parent of the my_item to the other window // the_other_window is a QQuickWindow QQuickWindow * the_other_window

How create a separate copy of a QQuickItem & render it on a different window

你离开我真会死。 提交于 2019-12-12 04:48:11
问题 I have a QQuickItem fetched from C++ side like this. QQuickItem * my_item = qmlEngine->rootObjects()[0]->findChild<QQuickItem*>("ItemObjectName"); my_item is valid & has all the properties set on to it. Scenario I have 2 windows which need this QQuickItem to be drawn on alterantively. I want to render this my_item to a different window. This works perfectly fine as long as I set the Parent of the my_item to the other window // the_other_window is a QQuickWindow QQuickWindow * the_other_window

QML Object Type is not a type error in QTCreator

无人久伴 提交于 2019-12-06 23:41:34
问题 Hi Everyone i am new to QT and i am having trouble loading one qml through another qml Basically i have created a qml MyTabView(MyTabView.qml) import QtQuick 2.3 import QtQuick.Controls 1.2 TabView { width: 360 height: 360 Component.onCompleted: { addTab("Tab 1", tab1) addTab("Tab 2", tab2) } Component { id: tab1 Rectangle {color: "red"} } Component { id: tab2 Rectangle {color: "blue"} } } and i am trying to show it through another qml(main.qml) which is in the same directory import QtQuick 2

How to get a valid instance of a QQuickItem on C++ side

给你一囗甜甜゛ 提交于 2019-12-02 05:26:54
问题 Alright. I have searched a lot but haven't got a good solution yet. I am new to Qt . I have a class which is a QQuickItem like so, class MyQuickItemClass : public QQuickItem { Q_OBJECT SetInfo(SomeCppClass object) }; I do a qmlRegisterType in my main.cpp to register it on the qml side like this, qmlRegisterType< MyQuickItemClass >("MyQuickItemClass", 1, 0, "MyQuickItemClass"); All fine till here. But -> I want to set an object instance & some properties in MyQuickItemClass which some C++

How to get a valid instance of a QQuickItem on C++ side

百般思念 提交于 2019-12-02 01:09:48
Alright. I have searched a lot but haven't got a good solution yet. I am new to Qt . I have a class which is a QQuickItem like so, class MyQuickItemClass : public QQuickItem { Q_OBJECT SetInfo(SomeCppClass object) }; I do a qmlRegisterType in my main.cpp to register it on the qml side like this, qmlRegisterType< MyQuickItemClass >("MyQuickItemClass", 1, 0, "MyQuickItemClass"); All fine till here. But -> I want to set an object instance & some properties in MyQuickItemClass which some C++ logic in it as well & then pass the MyQuickItemClass object to qml . Or, get a valid instance of