QMetaObject::connectSlotsByName: No matching signal for on_pushButton_clicked()
Hi friends,
I am working on a GUI project. I have 2 .ui files [I][B]mainwindow.ui[/B][/I] and [I][B]mapsmainwindow.ui[/B][/I].
My [I][B]main.cpp[/B][/I] contains the folowing etails:
[CODE]#include <QtGui/QApplication>
#include "mainwindow.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
#if defined(Q_WS_S60)
w.showMaximized();
#else
w.show();
#endif
return a.exec();
}[/CODE]
[I][B]mainwindow.h[/B][/I] contains:
[CODE]public Q_SLOTS: //slots to receive action of menu trigger.
void ShowAction();
private slots:
void on_pushButton_clicked();[/CODE]
In [I][B]mainwindow.cpp[/B][/I] I am trying to use the following 2 functions like :
[CODE]void MainWindow::ShowAction()
{
MapsMainWindow w;//Loads mapsmainwindow.ui
#if defined(Q_WS_S60)
w.showMaximized();////mapsmainwindow.ui displayed in maximized mode
#else
w.show();
#endif
}
void MainWindow::on_pushButton_clicked()
{
ShowingAction();
}[/CODE]
With above implementations I am able to Build successfully, but when the application is installed on device, it is giving warnings every time i clicked the pushButton and nothing happens:
Warnings are like:
[CODE][Qt Message] QMetaObject::connectSlotsByName: No matching signal for on_pushButton_clicked()
[Qt Message] QMetaObject::connectSlotsByName: No matching signal for on_pushButton_clicked()
[/CODE]
Please guide me on this issue.
Thanks...
Re: QMetaObject::connectSlotsByName: No matching signal for on_pushButton_clicked()
Do you set "pushButton" name for your button?
[url]http://doc.trolltech.com/4.6/qobject.html#objectName-prop[/url]
Re: QMetaObject::connectSlotsByName: No matching signal for on_pushButton_clicked()
yes.
[B][I]ui_mainwindow.h[/I][/B]contains this button.
[QUOTE]class Ui_MainWindow
{
public:
QWidget *centralWidget;
QPushButton *pushButton;
void setupUi(QMainWindow *MainWindow)
{
if (MainWindow->objectName().isEmpty())
MainWindow->setObjectName(QString::fromUtf8("MainWindow"));
MainWindow->resize(469, 640);
centralWidget = new QWidget(MainWindow);
centralWidget->setObjectName(QString::fromUtf8("centralWidget"));
centralWidget->setEnabled(true);
pushButton = new QPushButton(centralWidget);
pushButton->setObjectName(QString::fromUtf8("pushButton"));
pushButton->setGeometry(QRect(150, 320, 101, 41));
MainWindow->setCentralWidget(centralWidget);
pushButton->raise();
retranslateUi(MainWindow);
QMetaObject::connectSlotsByName(MainWindow);
} // setupUi[/QUOTE]
Re: QMetaObject::connectSlotsByName: No matching signal for on_pushButton_clicked()
Where are your connect() statements?
Re: QMetaObject::connectSlotsByName: No matching signal for on_pushButton_clicked()
This is really strange. Can you share the whole project?
Re: QMetaObject::connectSlotsByName: No matching signal for on_pushButton_clicked()
[QUOTE=danhicksbyron;761366]Where are your connect() statements?[/QUOTE]
QMetaObject::connectSlotsByName is used instead.
Re: QMetaObject::connectSlotsByName: No matching signal for on_pushButton_clicked()
I'm guessing it can't be a private slot and be connected from another object. It can be private and have MainWindow execute a connect(), however.
Re: QMetaObject::connectSlotsByName: No matching signal for on_pushButton_clicked()
[QUOTE=danhicksbyron;761366]Where are your connect() statements?[/QUOTE]
I don't have any connect statements!!!
Re: QMetaObject::connectSlotsByName: No matching signal for on_pushButton_clicked()
[QUOTE=divanov;761371]QMetaObject::connectSlotsByName is used instead.[/QUOTE]
ui_mainwindow.hcontains this.
Re: QMetaObject::connectSlotsByName: No matching signal for on_pushButton_clicked()
[QUOTE=danhicksbyron;761372]I'm guessing it can't be a private slot and be connected from another object. It can be private and have MainWindow execute a connect(), however.[/QUOTE]
I made it public but same thing happens:
[QUOTE][Qt Message] QMetaObject::connectSlotsByName: No matching signal for on_pushButton_clicked()[/QUOTE]
Re: QMetaObject::connectSlotsByName: No matching signal for on_pushButton_clicked()
Hey...
Little update on this issue.
In mainwindow.cpp I have changed the following 2 functions like :
[QUOTE]void MainWindow::ShowAction()
{
/*MapsMainWindow w;//Loads mapsmainwindow.ui
#if defined(Q_WS_S60)
w.showMaximized();////mapsmainwindow.ui displayed in maximized mode
#else
w.show();
#endif*/
QMessageBox msgBox;
msgBox.setInformativeText("slot executed...");
msgBox.setStandardButtons(QMessageBox::Ok);
int ret = msgBox.exec();
}
void MainWindow::on_pushButton_clicked()
{
ShowingAction();
}[/QUOTE]
The above code is executed and message is displayed when I click the Button. How ever When I tried to call another UI ([QUOTE]MapsMainWindow w; w.showMaximized();[/QUOTE]) it is giving the warning explained before. [QUOTE][Qt Message] QMetaObject::connectSlotsByName: No matching signal for on_pushButton_clicked()[/QUOTE]
Why is this thing happening....Is there any differentiation between the 2 implementations in the [QUOTE]void MainWindow::ShowAction()[/QUOTE] function?
Re: QMetaObject::connectSlotsByName: No matching signal for on_pushButton_clicked()
The reason for this message is that you have an object with slot [I]on_pushButton_clicked[/I] and this object doesn't have an object with name [I]pushButton[/I] among its children or this object doesn't have [I]clicked[/I] signal.
Re: QMetaObject::connectSlotsByName: No matching signal for on_pushButton_clicked()
[QUOTE=divanov;761783]The reason for this message is that you have an object with slot [I]on_pushButton_clicked[/I] and this object doesn't have an object with name [I]pushButton[/I] among its children or this object doesn't have [I]clicked[/I] signal.[/QUOTE]
Ok divanov,
then how can I call another UI window by a button click. Do I need to do some thing extra to load another window like the follow piece of code?
[QUOTE]MapsMainWindow w;//Loads mapsmainwindow.ui
w.showMaximized();////mapsmainwindow.ui displayed in maximized mode[/QUOTE]
Re: QMetaObject::connectSlotsByName: No matching signal for on_pushButton_clicked()
[QUOTE=RajeevSahu;761807]then how can I call another UI window by a button click.[/QUOTE]
One of the possible solutions:
[url]http://wiki.forum.nokia.com/index.php/How_to_create_and_destroy_stackable_windows_in_Maemo_5[/url]
Re: QMetaObject::connectSlotsByName: No matching signal for on_pushButton_clicked()
[QUOTE=divanov;761821]One of the possible solutions:
[url]http://wiki.forum.nokia.com/index.php/How_to_create_and_destroy_stackable_windows_in_Maemo_5[/url][/QUOTE]
Hey...
I have tried as per the link provided by You but I am getting one error like:
[QUOTE]undefined reference to `MainScreen::MainScreen(QWidget*)' [/QUOTE]
The file contents are as follows:
mainwindow.h..............
[QUOTE]#include <QMainWindow>
#include "screen.h"
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
private:
void CreateButton();
private slots:
void buttonClicked(bool checked = false);
void windowDestroyed(QObject* obj = 0);
private:
MainScreen *mainScreen;
};[/QUOTE]
mainwindow.cpp........
[QUOTE]#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QMessageBox>
#include <QPushButton>
#include <QDebug>
//#include "screen.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),mainScreen(0),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
setWindowTitle("DisplayMyWindow");
CreateButton();
}
void MainWindow::buttonClicked(bool checked)
{
Q_UNUSED(checked);
if (!mainScreen) {
mainScreen = new MainScreen(this);
mainScreen ->setAttribute(Qt::WA_DeleteOnClose);
connect(mainScreen, SIGNAL(destroyed(QObject*)),this, SLOT(windowDestroyed(QObject*)));
mainScreen->showMaximized();
qDebug() << "Show Map" << mainScreen;
}
}
void MainWindow::windowDestroyed(QObject* obj)
{
disconnect(obj, SIGNAL(destroyed(QObject*)),this, SLOT(windowDestroyed(QObject*)));
qDebug() << "No Show Map" << mainScreen;
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::CreateButton()
{
QPushButton *startmapBtn = new QPushButton();
startmapBtn->setText("MapStart");
startmapBtn->setGeometry(QRect(150, 400, 135, 50));
connect(startmapBtn, SIGNAL(clicked(bool)), this, SLOT(buttonClicked(bool)));
}[/QUOTE]
screen.h......
[QUOTE]
#include "ui_showmap.h"
#include <QtGui>
#include <QWidget>
#include <QWebView>
#include <QStandardItemModel>
class MainScreen : public QWidget ,public Ui::Form
{
Q_OBJECT
public :
MainScreen(QWidget *parent=0);
public slots :
void on_button1_clicked();
};[/QUOTE]
screen.cpp......
[QUOTE]
#include "screen.h"
#include "ui_showmap.h"
#include <QWebView>
#include <QHeaderView>
#include <QWebFrame>
#include <QWebPage>
MainScreen::MainScreen(QWidget *parent):QWidget(parent)
{
setupUi(this);
//map->load(QUrl("http://www.trolltech.com/"));
//map->load(QUrl("./index.html") ) ;
}
void MainScreen::on_button1_clicked()
{
//map->clearCoordinates();
//map->geoCode("Campina Grande");
}[/QUOTE]
Please help me to figure out the problem!