Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Confusion about signals/slots
Qt 6.11 is out! See what's new in the release blog

Confusion about signals/slots

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 3 Posters 488 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SillieWous
    wrote on last edited by
    #1

    Hey,

    I am very new to Qt and this question will have probably already been answered a dozen times (although I cannot find it). The program I'm writing basically creates a QDockWidget of which I want to connect the visibilityChanged(bool) signal to a custom slot that then checks/unchecks a menu item. It all works as I expect the problem I'm having is I get the error message

    QMetaObject::connectSlotsByName: No matching signal for on_actionFirstDock_visibilityChanged(bool)
    

    And I don't really understand what the problem is since it is working correctly.

    In mainwindow.h I declare:

    private slots:
        void on_actionFirstDock_visibilityChanged(bool visible);
    

    mainwindow.cpp

     MainWindow::MainWindow(QWidget *parent) :
         QMainWindow(parent),
         ui(new Ui::MainWindow){
         ui->setupUi(this);
    
         firstDock = new QDockWidget(this);
    
         connect(firstDock,SIGNAL(visibilityChanged(bool)),this,SLOT(on_actionFirstDock_visibilityChanged(bool)));
     }
     void MainWindow::on_actionFirstDock_visibilityChanged(bool visible){
         ui->actionFirst_menu->setChecked(visible);
     }
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      That's because you named your slot the same way as is expected for the auto connection feature.

      Just remove the underscores (and make it full camelcase for easier reading) and you should be good to go.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi
        as a note , you might want to know about the new syntax
        https://wiki.qt.io/New_Signal_Slot_Syntax
        Its better than the SIGNAL/SLOT macros as it fails compile time and not
        run time if something is not right.

        1 Reply Last reply
        2

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved