Object::connect: No such slot QApplication::MYSLOT()
-
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@ -
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_OBJECTpublic:
MyWidget(QWidget *parent = 0);public slots:
void easy();private:
int manera;
};class ActividadesTIC : public QMainWindow
{
// Q_OBJECTpublic:
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_OBJECTpublic:
MyWidget(QWidget *parent = 0);public slots:
void easy();private:
int manera;
};class ActividadesTIC : public QMainWindow
{
// Q_OBJECTpublic:
explicit ActividadesTIC(QWidget *parent = 0); ~ActividadesTIC();private:
Ui::ActividadesTIC *ui;
};#endif // ACTIVIDADESTIC_H
@
-
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.
-
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);
} -
Hi sushant,
- You forget add Q_OBJECT in your custom class.
- Please wrap your code between <code>@ and @<code>
BTW,
You can start a new thread for your question next time.