开发者

Qt push button event using Qt Designer not working: "No such slot QApplication"

I've read several articles about push button events in Qt b开发者_Python百科ut none seem to solve my problem. I have a simple GUI built with Qt Designer which only contains one button. The run-time error I get is the following:

Object::connect: No such slot QApplication::FullSizeR() in CameraWindow.h:25 Object::connect: (sender name: 'FullSize') Object::connect: (receiver name: 'CameraViewer')

FullSizeR() is the function I want called when My button is pushed.

Here's' how main is defined:

int main(int argc, char *argv[]) {
// initialize resources, if needed
// Q_INIT_RESOURCE(resfile);

QApplication app(argc, argv);
CameraWindow cw;
cw.show();
//app.setActiveWindow(&cw);
//cw.getData();       // this paints the window  
return app.exec();
}

And this is how CameraWindow is defined:

class CameraWindow : public QDialog{
Q_OBJECT
public:
bool serverConnected;
void getData();
CameraWindow()
{
    widget.setupUi(this); //this calls Qt Designer code
    //the function bellow produces a run-time error
    //access the button via widget.FullSize
    connect(widget.FullSize,SIGNAL(clicked()), qApp, SLOT(FullSizeR()));
}
QLabel *imgl;
virtual ~CameraWindow();
protected slots:
    void FullSizeR();
private:
    Ui::CameraWindow widget;
};

I've properly included QObject and my function definition under 'slots' This is the definition of FullSizeR:

void CameraWindow::FullSizeR()
{
   QMessageBox::information(this,"Button clicked!\n", "Warning");
}

The above doesn't seem to be hard to solve. I know its something simple if I only knew Qt a bit better :-/

Thanks All


connect(widget.FullSize,SIGNAL(clicked()), qApp, SLOT(FullSizeR()));

The error message says it all: qApp doesn't have the slot. You need this:

connect(widget.FullSize, SIGNAL(clicked()), this, SLOT(FullSizeR()));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜