Skip to content
  • 0 Votes
    6 Posts
    2k Views
    devDawgD

    @KillerSmath Its working! NOTIFY did the trick. The final touch that I also included was to use a Q_INVOKABLE getModuleAt(i) instead of a Q_INVOKABLE getTextBodyAt(i); this allowed me direct access to the DataModule's property:

    Text{ text: dataModel.getModuleAt(index).TextBody }

    portion of datamodule.h:

    class DataModule: public QObject { Q_OBJECT Q_PROPERTY(QString TextBody MEMBER textBody NOTIFY textBodyChanged) . . . signals: void newVal(DataPiece*); void textBodyChanged(QString newText);

    Q_INVOKABLE method inside of the QML context class datamodel.h:

    Q_INVOKABLE DataModule *getModuleAt(int i);

    Brilliant! Thanks for the help mate. Hopefully this is helpful to others as well.

  • 0 Votes
    3 Posts
    2k Views
    E

    @diredko Why passing it once using a normal function (Q_INVOKABLE) would hurt performance in your opinion? It would certainly be more efficient to have a big list in QML than use a function again and again, and such a list isn't big for modern hardware (couple of hundreds of KBytes maybe). If you can afford to have that list in C++ you should be able to afford to have it in QML, too.

    I think the biggest performance obstacle is that the system isn't real-time, QML may do garbage collection and animation isn't fluent. I recommend just testing with the most easy solution in the lowest end hardware it will be run on and deciding after that if it's enough.

  • 0 Votes
    9 Posts
    5k Views
    W

    @Chris-Kawa Thanks for the information provided. Then I need to re-design my implementation accordingly to this limitation.

  • 0 Votes
    13 Posts
    9k Views
    kshegunovK

    @ttuna
    Hello,
    Thanks, I know that. I wanted to have a method of my private object to be queued for later execution, because the ChildAdded event that I'm handling in an event filter is propagated before the child object is fully constructed. It appears that the gadgets have no such capability so I've implemented the functionality as a private slot, and it works okay. For anyone that might be interested, here's how:

    class AGUI_API AgDial : public QStackedWidget { Q_OBJECT // ... private: Q_PRIVATE_SLOT(d(), void scheduleChildAdd(QPointer<QObject>)) };

    With the corresponding invocation in the event filter:

    bool AgDial::eventFilter(QObject * object, QEvent * event) { switch (event->type()) { case QEvent::ChildAdded: QMetaObject::invokeMethod(this, "scheduleChildAdd", Qt::QueuedConnection, Q_ARG(QPointer<QObject>, QPointer<QObject>(reinterpret_cast<QChildEvent *>(event)->child()))); break; // ... } }

    Kind regards.