-1

Consider a scenario in which a button is defined in QML:

Page{
    Container{
        Button{
            text:"click the button"
            onclicked
            {
                //action performed by the button
            }
        }
    }
}

The usual way is to handle click events inside QML with a signal handler (as done above). My question is: is it possible to handle the event in C++? In term of code, is it possible to perform something like this:

{
    Button *b1 = root->findChild<Button*>("button_object");
    QObject::connect(b1,SIGNAL(clicked()),this,SLOT(buttonActionToBePerformed()));
}

void buttonActionToBePerformed()
{
    //button action to be performed is written here
}
BaCaRoZzo
  • 7,502
  • 6
  • 51
  • 82

1 Answers1

0

Short answer is yes.

Long answer, your assumptiont hat the usual way to handle click evens in QML is incorrect. It is up to the developer how much use is made of QML, and how much use is made of C++. Each paradigm has advanages and disavantages.

Richard
  • 8,920
  • 2
  • 18
  • 24