Questions tagged [qqmlcontext]

13 questions
5
votes
0 answers

Changing the QQmlContext for a QML object?

Evidently, even when objects are detached from the existing parent and attached to a new one, when the old parent context is destroyed, so is the object. The first solution that comes to mind is to create the object in a persistent context. However,…
dtech
  • 47,916
  • 17
  • 112
  • 190
3
votes
0 answers

Qt - How to dynamically insert Qml objects from C++ class

I need an advice about my simple QT/QML application. I have the following situation: about the interface, I have a main area called 'flickableArea' (flickableArea.qml) divided into four areas (item slot1, item slot2, item slot3 and item slot4). Each…
daniele86
  • 147
  • 3
  • 14
2
votes
1 answer

Can I access, from C++, the QQmlContext in which a QtObject is contained?

I have a sorta-singleton helper object that, however, I don't want to be actually a singleton, because I prefer to put things on the stack/heap. So I created it on the heap and set it as a contextProperty of my root QQmlContext. I also have a…
Stefan Monov
  • 11,332
  • 10
  • 63
  • 120
1
vote
1 answer

Create qml object dynamically from c++ object (by using setContextProperty)

I am trying to create a qml object dynamically in c++ using the object of c++ class. Below is the minimal code for my approach. Upon execution of this code and after clicking, the application is crashing(see the comment in main.qml). I have pasted…
nayab
  • 2,332
  • 1
  • 20
  • 34
1
vote
1 answer

expose a C++ object to QML and listen to change events

I have an object that I define in C++ and am trying expose a member string to QML. The class is defined as: #ifndef MYTYPE_H #define MYTYPE_H #include #include class MyType : public QObject { Q_OBJECT Q_PROPERTY(QString…
Luca
  • 10,458
  • 24
  • 107
  • 234
1
vote
1 answer

Load data from c++ to a QML Scatter3d Item

I am trying to develop a modified version of the example "qmlscatter", available in Qt examples. My intention is to plot a flight trajectory in the 3D environment, by modifying the data points of the "Data.qml" file. The actual coordinates of the…
0
votes
0 answers

How to get QQuickWindow from QQmlEngine or QQmlContext?

I have the QQmlEngine and QQmlContext pointer with me. Is it somehow possible to get the QQuickWindow pointer of in the Qt application?
TheWaterProgrammer
  • 7,055
  • 12
  • 70
  • 159
0
votes
2 answers

Custom view with model and delegate both accessible from both QML files

Although I already figured it out, it took quite a while. If you know a less convoluted solution - please share. I'd like to provide a custom View that works with any type of model (with arbitrarily named fields): model: 3 model: [ "red", "yellow",…
Jack White
  • 896
  • 5
  • 7
0
votes
1 answer

How to pass table-model data to qml?

I see some code write in c++ style, and I try to write it in python style. I write a table model in python file, and then pass it to qml file. But when I run my main.py file, The windows show nothing. And my program don't show any error and I don't…
jett chen
  • 1,067
  • 16
  • 33
0
votes
1 answer

connect signal emitted from c++ to qml Connections

I am emitting a signal from c++ and trying to fetch the values using Connections in qml. The codes are compiling however, due to some unknown reason qml is not able to recognise "OnSomethingHappened" and signal emitted from c++ is…
Mandeep
  • 335
  • 3
  • 13
0
votes
1 answer

Is it possible to list context property names of QQmlContext?

I am wondering if it's possible to get all context property names of specific QQmlContext. So I can do something like: QQmlContext *ctx = ...; for (auto contextPropertyName: ctx->getPropertyNames()) { qDebug() << contextPropertyName <<…
elderapo
  • 370
  • 2
  • 12
0
votes
1 answer

Setting QML context fail

I am trying to connect a C++ class to QML but I am facing a problem, the following errors appear when compile. I am adding an image to show the errors: I am using a simple class just to test if my code works , here is the code testing.h: #ifndef…
Meddah Abdallah
  • 654
  • 1
  • 7
  • 25
-1
votes
1 answer

Instantiate a c++ class in FileDialog (QtQuick Object), report error: Cannot assign object to property

Codes: //main.qml import im.sniper.DgConfigFileHandler 1.0 import QtQuick.Dialogs 1.2 ... FileDialog{ id: fileDlg DgConfigFileHandler {id: dgCfgFileHandler2} } I complie codes well and run, then get errors like: QML debugging is enabled.…
Crawl.W
  • 403
  • 5
  • 17