Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to grab events of QCheckbox inside a QWidget ?



  • Hello,

    I'm trying to make an application where the user can record a sequence of button clicks, checkbox checks, mouse move, ... And replay it later.

    I heard the best is to use an event filter to record interesting events and then replay it later. So I'm trying to get the events of a QCheckbox click but unfortunatly, i can't get any event of it.

    
        QWidget* centralWidget = new QWidget();
        centralWidget->setLayout( m_mainLayout );
        setCentralWidget( centralWidget );
        
        m_recorder.setObj(centralWidget); // The event filter will be placed on it.
    
        addAction( m_console->action() );
    
        statusBar()->addWidget( m_status );
        statusBar()->layout()->setMargin( 9 );
    
        QCheckBox *dynamic = new QCheckBox("check 1");
        dynamic->setChecked (true);
    
        addWidgetToColumn(1,dynamic); // It's adding the QCheckbox in the centralWidget 
    

    Has anyone deal with this and can help me ?
    Thank you.



  • @FCastle

    QCheckBox *dynamic = new QCheckBox("check 1");
    dynamic->setChecked (true);
    
    // use connect(dynamic...) to capture the signal from the checkbox. can be a lambda as well. this is the spot you need to act on.
    
    addWidgetToColumn(1,dynamic); // It's adding the QCheckbox in the centralWidget


  • @artwaw Hello, I don't need to get the signal, i just need to get the event of click to replay it later. Here is the step :

    1. User start recording
    2. User click on Checkbox
    3. User stop recording"
    4. User click "Replay"
    5. Software send all events stored in the list of recorded event ( It click the checkbox again)


  • @FCastle Well, good luck then!


Log in to reply