Run Time error: Object::connect: No such slot dlgTextScroller::pbPreview_clicked(app)
Dear ................!
I have a need of QApplication app(int argc,char **argv) variable (which is declared in main.cpp) in pbPreview_clicked() slot.
/*In dlgtextscroller.h I have defined the slot as follows*/
private slots:
virtual void pbPreview_clicked(QApplication *app);
/*In dlgTextScroller constructor I connected the pbPreview clicked( ) push button signal to dlgTextscroller pbPreview_clicked(app) as follows*/
dlgTextScroller::dlgTextScroller( QApplication *app, QWidget* parent)
: QDialog(parent)
{
setupUi(this);
connect( pbPreview, SIGNAL( clicked() ), this, SLOT( pbPreview_clicked(app) ));
}
void dlgTextScroller::pbPreview_clicked(QApplication *app)
{
...
...
...
}
It doesn't give any comile time error but when I ran, it gives the following error and show the dialog.........
Object::connect: No such slot dlgTextScroller::pbPreview_clicked(app)
Object::connect: (sender name: 'pbPreview')
Object::connect: (receiver name: 'dlgTextScroller')
Thanks in advance........!
Re: Run Time error: Object::connect: No such slot dlgTextScroller::pbPreview_clicked(
The QApplication object is accessible through the QCoreApplication::instance() function which return a pointer equivalent to the global qApp pointer
Re: Run Time error: Object::connect: No such slot dlgTextScroller::pbPreview_clicked(
Quote:
Originally Posted by
ashukla
connect( pbPreview, SIGNAL( clicked() ), this, SLOT( pbPreview_clicked(app) ));
You can't put values, variables and parameter names inside SLOT and SIGNAL macros.
You can store that pointer in a member variable -- there's no point in passing it as a parameter to a method of the same class. Another solution is to use QCoreApplication::instance().