Solved updating visibility based on QVariantList
-
Hi all -
I'm trying to build on my learning from this earlier thread. In my C++, I have a property defined:
private: QVariantList m_columnCapList; public: Q_PROPERTY( QVariantList columnCapStatus MEMBER m_columnCapList NOTIFY columnCapsUpdated) signals: void columnCapsUpdated(QVariantList columnCapsList);
And a singleton of this class is properly exposed to QML, etc. I fill this list with boolean values. Each element corresponds to a rectangle in a QML view; I want the rectangle's visibility to be derived from the value in the list. Here's what I've tried so far:
Repeater { id: columnCaps model: wellPlateColNames.length Rectangle { visible: issViewModel.columnCapStatus[index] x: 100 + index + (100) y: 100 + index + (100) height: 50 width: 50 color: 'pink' } }
But this doesn't work. I've also tried the Connections type, without success. I figure I'm probably over-thinking this (as usual), so...what's the crisp-and-clean way to set the rectangles' visibilities based on C++ data?
Thanks...
-
so...what's the crisp-and-clean way to set the rectangles' visibilities based on C++ data?
probably:
Repeater { id: columnCaps model: columnCapStatus Rectangle { visible: modelData x: 100 + index + (100) y: 100 + index + (100) height: 50 width: 50 color: 'pink' }
-
I'm getting an error at startup:
ReferenceError: columnCapList is not defined
I've renamed a few items, so I'm showing the definition again below:
Q_PROPERTY( QVariantList columnCapList MEMBER m_columnCapList NOTIFY columnCapsUpdated) Q_INVOKABLE bool getColumnCapStatus(int index); QVariantList m_columnCapList;
The QML:
Repeater { id: columnCaps model: columnCapList Rectangle { visible: modelData x: index + (50 * index) y: index - (50 * index) height: 50 width: 50 color: 'pink' }
Any idea what I'm doing wrong?
-
@mzimmers can you show the singleton exposure to the JSEngine ?
-
@J-Hilk this routine is called by a "master" exposure routine:
void IssApi::ExportContextPropertiesToQml(QQmlEngine *engine) { engine->rootContext()->setContextProperty("issViewModel", this); ...
-
-
Oh, sheesh...I can't believe I forgot that. Thanks, J.Hilk.