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. Object::connect: No such slot QApplication::MYSLOT()

Object::connect: No such slot QApplication::MYSLOT()

Scheduled Pinned Locked Moved General and Desktop
13 Posts 8 Posters 32.6k 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.
  • P Offline
    P Offline
    patowlmc
    wrote on last edited by
    #4

    Ok, so I've updated the program (& the post, you can check the "new code above"), but now I get this error: @Object::connect: No such slot QWidget::easy() in ..\ActividadesTIC\main.cpp:38@

    So now, i understand where's the problem. But how to fix it?

    NOTE: I tried: @connect ( easyWay, SIGNAL(clicked()), ActividadesTIC, SLOT(easy()) );@
    But it tells me: @expected primary expression before ',' token@

    1 Reply Last reply
    0
    • P Offline
      P Offline
      patowlmc
      wrote on last edited by
      #5

      FINALLY!!!

      Got it working guys.

      Do you expect me to post the working code? I'm doing so anyway: (NOTE: some of it is in spanish)

      O!! BTW: THANKS!!

      MY H FILE

      @
      #ifndef ACTIVIDADESTIC_H
      #define ACTIVIDADESTIC_H

      #include <QMainWindow>
      #include <QMessageBox>

      namespace Ui {
      class ActividadesTIC;

      }

      class MyWidget : public QWidget
      {
      Q_OBJECT

      public:
      MyWidget(QWidget *parent = 0);

      public slots:
      void easy();

      private:
      int manera;
      };

      class ActividadesTIC : public QMainWindow
      {
      // Q_OBJECT

      public:

      explicit ActividadesTIC(QWidget *parent = 0);
      ~ActividadesTIC();
      

      private:
      Ui::ActividadesTIC *ui;
      };

      #endif // ACTIVIDADESTIC_H

      @

      My main.cpp:
      @
      #ifndef ACTIVIDADESTIC_H
      #define ACTIVIDADESTIC_H

      #include <QMainWindow>
      #include <QMessageBox>

      namespace Ui {
      class ActividadesTIC;

      }

      class MyWidget : public QWidget
      {
      Q_OBJECT

      public:
      MyWidget(QWidget *parent = 0);

      public slots:
      void easy();

      private:
      int manera;
      };

      class ActividadesTIC : public QMainWindow
      {
      // Q_OBJECT

      public:

      explicit ActividadesTIC(QWidget *parent = 0);
      ~ActividadesTIC();
      

      private:
      Ui::ActividadesTIC *ui;
      };

      #endif // ACTIVIDADESTIC_H

      @

      1 Reply Last reply
      0
      • G Offline
        G Offline
        goetz
        wrote on last edited by
        #6

        Please do yourself a favor and include the Q_OBJECT macro in all QObject derived classes (QWidgets and subclasses count in!). You will save you a big bunch of problems, even if you do not need the functionality in the first place. So, please remove the commenting // in the second class.

        http://www.catb.org/~esr/faqs/smart-questions.html

        1 Reply Last reply
        0
        • P Offline
          P Offline
          patowlmc
          wrote on last edited by
          #7

          hahah, ok Thanks, And I'll do that from now and on

          1 Reply Last reply
          0
          • R Offline
            R Offline
            ReaMix
            wrote on last edited by
            #8

            When you posted your solution, you pasted the header file in the cpp section. I am having the same problem and am unable to resolve. I would appreciate seeing your working cpp code, if you still have it on hand.

            1 Reply Last reply
            0
            • G Offline
              G Offline
              goetz
              wrote on last edited by
              #9

              Please open a new thread and post your problem description with some code snippets there.

              http://www.catb.org/~esr/faqs/smart-questions.html

              1 Reply Last reply
              0
              • S Offline
                S Offline
                sushant
                wrote on last edited by
                #10

                Error :----QObject::connect: No such slot QDialog::mydata()

                My HeaderFile
                #ifndef DIALOG_H
                #define DIALOG_H
                #include <QDialog>
                #include<QLineEdit>
                #include<QPushButton>

                class Dialog : public QDialog
                {

                public:
                Dialog(QLineEdit *);
                QPushButton *apply;
                QLineEdit *line2;
                QLineEdit *oldLineEdit;
                private slots:
                void mydata();

                };

                #endif // DIALOG_H

                cpp file

                #include "Dialog.h"
                #include <QVBoxLayout>
                #include<stdio.h>
                Dialog::Dialog(QLineEdit *ledit)
                {
                apply = new QPushButton("Apply");
                line2 = new QLineEdit;
                oldLineEdit=ledit;
                QVBoxLayout *b = new QVBoxLayout;
                b->addWidget(line2);
                b->addWidget(apply);
                setLayout(b);
                QObject::connect(apply,SIGNAL(clicked()),this,SLOT(mydata()));
                }

                void Dialog::mydata(){
                printf("Enter the slot");
                QString str = line2->text();
                oldLineEdit->setText(str);
                }

                1 Reply Last reply
                0
                • IamSumitI Offline
                  IamSumitI Offline
                  IamSumit
                  wrote on last edited by
                  #11

                  hii Sushant......
                  It is inadequate --
                  QObject::connect(apply,SIGNAL),this,SLOT)); ?

                  Be Cute

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    sushant
                    wrote on last edited by
                    #12

                    hii sumit,
                    QObject::connect(apply,SIGNAL(clicked()),this,SLOT(mydata()));

                    1 Reply Last reply
                    0
                    • D Offline
                      D Offline
                      dbzhang800
                      wrote on last edited by
                      #13

                      Hi sushant,

                      1. You forget add Q_OBJECT in your custom class.
                      2. Please wrap your code between <code>@ and @<code>

                      BTW,
                      You can start a new thread for your question next time.

                      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