Ok, thanks so much for your suggestion, I made as you told me and if I pass a Widget to another class i can modify it.
But what's happen if i want to pass to another class a pointer to QMainWindow to have acces at all the interface members(I mean the ui_class Widget put with QT Designer).
Down here the code.
In ui_guiwid.h I just added a QLabel labelPark and an menù action actionChangeLabel.
On doSmt.cpp the main error.
Thanks
guiwid.h
#include <QtGui/QWidget>
#include "ui_guiwid.h"
{
Q_OBJECT
public:
guiwid();
~guiwid();
private slots:
void callDoStm();
private:
Ui::MainWindow ui;
};
#include <QtGui/QWidget>
#include "ui_guiwid.h"
class guiwid : public QMainWindow
{
Q_OBJECT
public:
guiwid();
~guiwid();
private slots:
void callDoStm();
private:
Ui::MainWindow ui;
};
To copy to clipboard, switch view to plain text mode
guiwid.cpp
#include "guiwid.h"
#include "doSmt.h"
#include <QtGui/QWidget>
guiwid::guiwid()
{
ui.setupUi(this);
connect(ui.actionChangeLabel, SIGNAL(triggered()), this, SLOT(callDoStm()));
}
guiwid::~guiwid()
{
}
void guiwid::callDoStm(){
doSmt *ds = new doSmt(ui.MainWindow);
ds->changeLabel();
}
#include "guiwid.h"
#include "doSmt.h"
#include <QtGui/QWidget>
guiwid::guiwid()
{
ui.setupUi(this);
connect(ui.actionChangeLabel, SIGNAL(triggered()), this, SLOT(callDoStm()));
}
guiwid::~guiwid()
{
}
void guiwid::callDoStm(){
doSmt *ds = new doSmt(ui.MainWindow);
ds->changeLabel();
}
To copy to clipboard, switch view to plain text mode
doSmt.h
#include <QtGui/QWidget>
#include <QMainWindow>
class doSmt
{
public:
~doSmt();
public:
void changeLabel();
};
#include <QtGui/QWidget>
#include <QMainWindow>
class doSmt
{
public:
doSmt(QMainWindow *mainWindow);
~doSmt();
public:
void changeLabel();
QMainWindow *mainWindow;
};
To copy to clipboard, switch view to plain text mode
doSmt.cpp
#include "doSmt.h"
#include <QtGui/QWidget>
#include <QLabel>
{
this->mainWindow = mainWindow;
}
doSmt::~doSmt()
{
}
void doSmt::changeLabel()
{
mainWindow->labelPark->setText("Yeap!"); //I can't access on this member
}
#include "doSmt.h"
#include <QtGui/QWidget>
#include <QLabel>
doSmt::doSmt(QMainWindow *mainWindow)
{
this->mainWindow = mainWindow;
}
doSmt::~doSmt()
{
}
void doSmt::changeLabel()
{
mainWindow->labelPark->setText("Yeap!"); //I can't access on this member
}
To copy to clipboard, switch view to plain text mode
Bookmarks