Qt No Such Signal Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business object::connect: no such signal Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation
Qobject::connect
Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just
Qregistermetatype
like you, helping each other. Join them; it only takes a minute: Sign up Qt - no such signal error up vote 8 down vote favorite 1 I'm trying to trigger a signal when a double click happens
Qt Connect
in one of the draggable widgets on the fridge magnets example. Here's the changes I made to the example source: DragLabel: class DragLabel : public QLabel { public: DragLabel(const QString &text, QWidget *parent); QString labelText() const; public slots: void testSlot(){qDebug()<<"testSlot";} //<-- implemented this slot protected: void mouseDoubleClickEvent(QMouseEvent *ev){emit testSignal();} //<-- overriden this method private: QString m_labelText; signals: void testSignal(); //<-- added this signal }; The only thing I changed in the implementation file is adding connect(this,SIGNAL(testSignal()),this,SLOT(testSlot())); to DragLabel's constructor. Trying to compile the project resulted in 'undefined reference to `DragLabel::testSignal()' and 'collect2: ld returned 1 exit status' errors. When I comment out the call to the signal, it compiles and runs, but gives off 'Object::connect: No such signal QLabel::testSignal() in draglabel.cpp' warning in the application output. Apparently testSignal() isn't being recognized as a signal. I've tried to add the Q_OBJECT macro to DragLabel but it results in 4 'undefined reference to `vtable for DragLabel'' warnings and a 'collect2: ld returned 1 exit status' error. What am I missing? qt signals-slots share|improve this question edited Apr 9 '10 at 19:24 asked Apr 9 '10 at 19:08 David McDavidson 1,58583053 Your sample code is missing the Q_OBJECT macro call, which might be the cause of your problems. –RA. Apr 9 '10 at 19:11 Oh yeah I forgot to mention that, I did try to add Q_OBJECT before. I'll add that to the question. –David McDavidson Apr 9 '10 at 19:20 add a comment| 2 Answers 2 active oldest votes up vote 12 down vote accepted Put the Q_OBJECT macro at the top, (must be first thing in the class and no ";" ) Make sure you do a full rebuild, the VS-add-in especially doesn't always notice that a file has become qt-aware without a rebuild. M
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Qt: “No http://stackoverflow.com/questions/2610151/qt-no-such-signal-error such signal” error up vote 2 down vote favorite I have a simple code; here I've two buttons, I press the first one and it shows a MsgBox. Then I press the "Okay", and it should call a connected action written in a second button, but it doesn't. Instead I get an error: Object::connect: No such signal QMessageBox::buttonClicked(QMessageBox::Ok) Object::connect: (receiver name: 'OpenFile_Bttn') The code: http://stackoverflow.com/questions/22957414/qt-no-such-signal-error #include "mainwindow.h" #include "ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_OpenFile_Bttn_clicked(){ QFileDialog::getOpenFileName(this,tr("Open file"), "", tr(""));//Open a dialog "OpenFile" } void MainWindow::on_pushButton_clicked(){ QMessageBox msgBox; msgBox.setText("Push button to choose a file"); //Connect clicking button in MsgBox to an action in OpenFile_Bttn button QWidget::connect(&msgBox,SIGNAL(buttonClicked(QMessageBox::Ok)), ui->OpenFile_Bttn, SLOT(on_OpenFile_Bttn_clicked())); msgBox.exec();//Show MsgBox } Also I found an interesting thing, that the error message appears when a MsgBox popup, but not when I click the button "Ok" inside the MsgBox. c++ qt share|improve this question edited Apr 9 '14 at 9:13 asked Apr 9 '14 at 8:54 Hi-Angel 1,36451640 3 I'm voting to close, because your question is a typographical error - SIGNAL(msgBox.buttonClicked(QMessageBox::Ok)) - you shouldn't add the member variable, it should be SIGNAL(buttonClicked(QMessageBox::Ok)) instead. In the future, use the intellisense (if you're in Qt Creator), it will prevent silly errors like that. Even the error text - No such signal QMessageBox::msgBox.buttonClicked should have alerted you, notice QMessageBox:: msgBox .buttonClicked. –sashoalm Apr 9 '14 at 9:02 Same as sashoalm. Also, your SLOT should be on_OpenFile_Bttn_clicked() rather than ui->OpenFile_Bttn->on_OpenFile_Bttn_clicked(). Use Qt creator can prevent this kind of e
download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript). Home Qt Development General and Desktop QObject::Connect no such https://forum.qt.io/topic/36731/qobject-connect-no-such-signal-error-but-cannot-see-anything-wrong signal error but cannot see anything wrong :( QObject::Connect no such signal error but cannot see anything wrong :( This topic has been deleted. Only users with topic management privileges http://qt-project.org/forums/viewthread/37316 can see it. kpks last edited by Hi My mainwindow class has 2 main objects, a dataDisp and a data Plotter. As a first step all I am trying to no such do is connect the peak detection in the dataDisp to the mainwindow with signals and slots before I try to connect it to the data display class. I have attached the mainwindow and dataDisp classes. But I keep getting no such signal errors. @#ifndef MAINWINDOW_H #define MAINWINDOW_H #include
void addData(int val, int index);
void updatePeakVals(int val, int index);
int getPeakDepth(){return peakDepth;}
int getTimeMark(){return markTime;}
signals:
void newPeakDepth(int peakDepth,int markTime);
private:
int startIndex;
int value;
int peakDepth;
int markTime;
int peakRecoil;
int compressionCount;
int compressionRate;
std::vector
std::vector
}; #endif // DISPDATA_H #include "mainwindow.h" #include "ui_mainwindow.h" #include "cprserver.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { const QString IP = "127.0.0.1"; const ushort port = 8100; ui->setupUi(this); rawData = new dispData (this); server = new cprServer(this,rawData,port); connect(this->rawData,SIGNAL(rawData->newPeakDepth(int,int)),this,SLOT(updatePeak(int, int))); } MainWindow::~MainWindow() { delete ui; } void MainWindow::u