signals and slots problem
hi,
If my lineedit control changes then a message has to be displayed.
I have dont like this.
Code:
public slots:
OnChangelineedit();
connect(lineedit1, SIGNAL(cursorPositionChanged(0,1)),
this, SLOT(OnChangelineedit()));
But i am getting error"
Quote:
Object::connect: No such signal QLineEdit::cursorPositionChanged(0,1)
Object::connect: (sender name: 'lineedit1)
Object::connect: (receiver name: 'dialog')".
What is wrong with my code.
Re: signals and slots problem
I recommend reading about signals and slots. You can't put parameter names or values but only parameter types in connect statement.
Re: signals and slots problem
How about this...
Code:
connect(lineedit1, SIGNAL(cursorPositionChanged(int, int)), this, SLOT(OnChangelineedit()));
Re: signals and slots problem
Hello,
I'm using Eclipse and QT4 and I get exactly the same problem but the previous post doesn't really help very much.
Code:
#ifndef TEST_QT_H
#define TEST_QT_H
#include <QtGui/QWidget>
#include "ui_test_qt.h"
{
Q_OBJECT
public:
~test_qt();
private:
Ui::test_qtClass ui;
public slots:
void test();
};
#endif // TEST_QT_H
Code:
#include "test_qt.h"
{
ui.setupUi(this);
connect(ui.pButton, SIGNAL(clicked()), ui.label, SLOT(test()));
}
test_qt::~test_qt()
{
}
void test_qt::test()
{
ui.label->setText("GO");
}
I get this error:
Code:
Object
::connect: No such
slot QLabel::test()Object::connect: (sender name: 'pButton')
Object::connect: (receiver name: 'label')
can somebody help me on this ?
thanks
Re: signals and slots problem
You are passing an incorrect receiver to the connect statement. QLabel does not have such slot as "test()". The test_qt class written by you does. So you should not pass "ui.label" but something else to the connect statement.
Re: signals and slots problem
Hell I have a similar problem, the error message I get is:
Object::connect: No such slot QWidget::adminstart()
If I add Q_OBJECT to my class, I get the following error msg when I type "make"
ndefined symbols:
"vtable for harpWin", referenced from:
__ZTV7harpWin$non_lazy_ptr in harpwin.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
Here is my code (all in one file ):
Code:
{
Q_OBJECT
public:
~harpWin();
public slots:
void adminstart();
};
{
setWindowTitle("Harp Win0");
adminButton->setDefault(true);
vboxLayout->addWidget(adminButton);//, 1, Qt::AlignRight);
vboxLayout->addWidget(measureButton);
vboxLayout->addWidget(viewButton);
vboxLayout->addWidget(quitButton);
hboxLayout->addWidget(graphicsView, 1, Qt::AlignLeft);
hboxLayout->addLayout(vboxLayout);
setLayout(hboxLayout);
QObject::connect(quitButton,
SIGNAL(clicked
()),
qApp,
SLOT(quit
()));
connect(adminButton, SIGNAL(clicked()), this, SLOT( adminstart() ));
QObject::connect(viewButton,
SIGNAL(clicked
()),
qApp,
SLOT(quit
()));
QObject::connect(measureButton,
SIGNAL(clicked
()),
qApp,
SLOT(quit
()));
}
harpWin::~harpWin()
{
}
void harpWin::adminstart()
{
QString str
= "\n clicked button\n";
qDebug() << str;
}
int main(int argc, char *argv[])
{
harpWin introWindow;
//introWindow.setWindowTitle("Absolute");
introWindow.show();
return app.exec();
}
Re: signals and slots problem
Quote:
Originally Posted by
windsword
If I add Q_OBJECT to my class, I get the following error msg when I type "make"
Do you use qmake? If yes, then you have to re-run it after you add Q_OBJECT macro.