Re: Qt signals slots again
Based on what you wrote I can't see an error. So could you please make a minimal, compilable example reproducing your problem.
1 Attachment(s)
Re: Qt signals slots again
Here you go. The full solution (VS 2010) is attached, I paste the code here for convenience. Thanks for help!
Code:
//A.h
#ifndef _A_H_
#define _A_H_
#include <qobject>
#include <qlayout.h>
#include <qpushbutton.h>
#include <qlineedit.h>
#include <QtGlobal>
#include <qapplication.h>
#include "IHasPropertiesPage.h"
class A
: public QObject,
public IHasPropertiesPage
{
Q_OBJECT
public:
A() {};
void showProperties
(QWidget* widget
);
signals:
void runThisBastard();
public slots:
void run();
private:
};
#endif
Code:
//A.cpp
#include "A.h"
void A
::showProperties(QWidget* widget
) {
//connect(this,SIGNAL(runThisBastard()),this,SLOT(run()));
//emit runThisBastard();
layout_->addWidget(edit_,0,0);
layout_->addWidget(buttonRun,1,0);
widget->setLayout(layout_);
//connect(buttonRun,SIGNAL(clicked()),qApp,SLOT(aboutQt()));
connect(buttonRun,SIGNAL(clicked()),this,SLOT(run()));
}
void A::run()
{
int i = 0; //just do something, I set a breakpoint here
}
Code:
//tempqt.cpp
#include "tempqt.h"
#include "A.h"
tempQt
::tempQt(QWidget *parent, Qt
::WFlags flags
){
ui.setupUi(this);
A a;
a.showProperties(ui.centralWidget);
}
tempQt::~tempQt()
{}
Code:
//tempqt.h
#ifndef TEMPQT_H
#define TEMPQT_H
#include <QtGui/QMainWindow>
#include "ui_tempqt.h"
{
Q_OBJECT
public:
tempQt
(QWidget *parent
= 0, Qt
::WFlags flags
= 0);
~tempQt();
private:
Ui::tempQtClass ui;
};
#endif // TEMPQT_H
Code:
//IHasPropertiesPage.h
#ifndef _IHASPROPERTIESPAGE_H_
#define _IHASPROPERTIESPAGE_H_
#include <qwidget.h>
class IHasPropertiesPage
{
public:
virtual void showProperties
(QWidget* widget
) = 0;
};
#endif
Attachment 7150
Re: Qt signals slots again
Well A::run() could not be reached, since it is long go... It is deleted after the c-tor (Basic C++ :eek:)! So make A a private member or create it on the heap.
Re: Qt signals slots again
Wow, this is stupid of me. Thanks!