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

How to implement new signal / slot ?



  • OK,
    I have a cut and paste code "adding new action " to MDI.
    I cannot find anywhere how to add new signal / slot utilizing BOTH QtCreator and QDesigner.

    I am looking for something like flow chart

    1. add "slot " (declaration ? ) to class header under

    private slots:
    void on_actionAddWindow_triggered();
    // add
    void on_TEST_Action();

    1. code "slot" (definition ?) in class .cpp file

    etc....

    I can figure out piece parts , but I am not sure "who is on first" sequence of additions.

    ADDENDUM
    After what seems typical in Qt development - few dead ends and realization that mixing QtCreator and QDesigner is not good idea.
    Yes and for you who member - I have asked this way back when I started with Qt. Not much changed since. There are very few "connections" between QtCreator and QDesiger when it comes to Qt main features - GUI and event processing It looks as three separate development groups who do not care to talk to each other.
    Too bad.
    .


  • Moderators

    @AnneRanch said in How to implement new signal / slot ?:

    I am looking for something like flow chart

    1. add "slot " (declaration ? ) to class header under

    private slots:
    void on_actionAddWindow_triggered();
    // add
    void on_TEST_Action();

    1. code "slot" (definition ?) in class .cpp file

    etc....

    The steps you described above are correct for slots. You do exactly the same thing as if you're implementing a new function/method.

    Just make sure that the name and parameters in the .h file match those in the .cpp file:

    // .h
    
    MainWindow : public QMainWindow {
       /* ... */
    
    private slots:
        void on_actionAddWindow_triggered();
    };
    
    // .cpp
    void MainWindow::on_actionAddWindow_triggered() {
        // Add your logic here
    }
    

    I cannot find anywhere how to add new signal / slot utilizing BOTH QtCreator and QDesigner.

    Qt Designer is mainly for setting the visual layout. You don't need it to implement new signals/slots.


Log in to reply