Here you go. The full solution (VS 2010) is attached, I paste the code here for convenience. Thanks for help!
//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
//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:
QLineEdit* edit_;
};
#endif
To copy to clipboard, switch view to plain text mode
//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
}
//A.cpp
#include "A.h"
void A::showProperties(QWidget* widget)
{
edit_ = new QLineEdit(QString::number(0.1));
QPushButton* buttonRun = new QPushButton(QString("Run"));
//connect(this,SIGNAL(runThisBastard()),this,SLOT(run()));
//emit runThisBastard();
QGridLayout* layout_ = new QGridLayout;
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
}
To copy to clipboard, switch view to plain text mode
//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()
{}
//tempqt.cpp
#include "tempqt.h"
#include "A.h"
tempQt::tempQt(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
{
ui.setupUi(this);
A a;
a.showProperties(ui.centralWidget);
}
tempQt::~tempQt()
{}
To copy to clipboard, switch view to plain text mode
//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
//tempqt.h
#ifndef TEMPQT_H
#define TEMPQT_H
#include <QtGui/QMainWindow>
#include "ui_tempqt.h"
class tempQt : public QMainWindow
{
Q_OBJECT
public:
tempQt(QWidget *parent = 0, Qt::WFlags flags = 0);
~tempQt();
private:
Ui::tempQtClass ui;
};
#endif // TEMPQT_H
To copy to clipboard, switch view to plain text mode
//IHasPropertiesPage.h
#ifndef _IHASPROPERTIESPAGE_H_
#define _IHASPROPERTIESPAGE_H_
#include <qwidget.h>
class IHasPropertiesPage
{
public:
virtual void showProperties
(QWidget* widget
) = 0;
};
#endif
//IHasPropertiesPage.h
#ifndef _IHASPROPERTIESPAGE_H_
#define _IHASPROPERTIESPAGE_H_
#include <qwidget.h>
class IHasPropertiesPage
{
public:
virtual void showProperties(QWidget* widget) = 0;
};
#endif
To copy to clipboard, switch view to plain text mode
tempQt.zip
Bookmarks