Skip to content
  • 0 Votes
    13 Posts
    4k Views
    Pl45m4P

    @Burke212

    One more thing... :)
    So you create 10 Buttons and connect them somehow to "numPressed", that prints or computes the button-number, if a button is clicked + released, right?

    The use of a QButtonGroup would make this even easier.
    https://doc.qt.io/qt-5.6/qbuttongroup.html

    Add your buttons to your buttonGroup and setID of each button.
    ButtonGroup also provides signals and functions to work with. Maybe your own connection is not necessary anymore and you dont need to rename every single button, because you can work with the groupID.

    When adding the buttons to your group, set your own IDs, as the default buttonID in a buttonGroup starts at -2 and decreases with every additional button (this gave me headache in one of my projects some time ago... Of course, I didnt set my own IDs and was expecting the ID to start at 0 increasing. And of course I didnt read the Docs of the addButton-Function back then) :)

  • 0 Votes
    3 Posts
    6k Views
    E

    @sierdzio Thanks for your input! The this-object was the parent widget holding the QQuickView. I solved it by saving the root object of the QQuickView:

    QObject *obj = quickview->rootObject(); if (obj) obj->setProperty("ticks", tick_count); else qDebug() << "Could not set tick count!";

    Anyway, I'll have a look at the different approach you suggest. It sound like a more robust way of interacting with QML.

    Best regards, E

  • 0 Votes
    1 Posts
    2k Views
    No one has replied
  • 0 Votes
    4 Posts
    11k Views
    P

    @p3c0 said:

    Cast to QObject instead of QQuickItem.

    That works. :)
    Thanks.