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. [Solved] Slot not found

[Solved] Slot not found

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 2.0k Views 1 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
    silep
    wrote on last edited by
    #1

    Hello, I wrote a signal/slot connect in a slot, but the debug doesn't find it.. It is written just before so I really don't know why. Here are my code lines:

    In mainform.h:

    @class MainForm : public QMainWindow
    {
    Q_OBJECT

    private slots:
    void HandleOK();
    void HandleCancel();
    void on_pbChangeLensPlateXYScan_clicked();
    };@

    In mainform.cpp:
    @

    void MainForm::HandleOK()
    {
    ui->teErrorBrowser->insertPlainText("OK!!");
    this->close();
    }

    void MainForm::HandleCancel()
    {
    ui->teErrorBrowser->insertPlainText("Cancel!!");
    this->close();
    }

    void MainForm::on_pbChangeLensPlateXYScan_clicked()
    {
    QMainWindow mwLensPlateChoice = new QMainWindow(this);
    QDialogButtonBox bbValidation;
    /
    definition of the two widgets...
    /

    QPushButton* OkButton = bbValidation->button(QDialogButtonBox::Ok);
    connect(OkButton, SIGNAL(clicked()), mwLensPlateChoice, SLOT(HandleOK()));
    QPushButton* CancelButton = bbValidation->button(QDialogButtonBox::Cancel);
    connect(CancelButton, SIGNAL(clicked()), mwLensPlateChoice, SLOT(HandleCancel()));@

    The slots HandleOK() and HandleCancel() are not found..

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      mwLensPlateChoice is a QMainWindow, not a MainForm

      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
      0
      • S Offline
        S Offline
        silep
        wrote on last edited by
        #3

        Thanks you for your reply! Yes you are right the slots are defined in MainForm, so I have to move them to qmainwindow.cpp? I hesitate to change the default files..

        Another solution should to change mwLensPlateChoice into a MainForm, because it is almost the same thing, but the method is in the MainForm class, so it doesn't work!

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          You certainly should not touch QMainWindow for that.

          From your questions, you really should first look through Qt's documentation examples and tutorials.

          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
          0
          • S Offline
            S Offline
            silep
            wrote on last edited by
            #5

            I found another way, I just passed mwLensPlateChoice as a MainForm attribute, so that I can use it without input parameter in my slot functions, and put "this" for the receiver in my connect.

            1 Reply Last reply
            0

            • Login

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