it's code for example:
ui.h:
#ifndef UI_GUI_H
#define UI_GUI_H
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QLabel>
#include <QtGui/QMainWindow>
#include <QtGui/QMenuBar>
#include <QtGui/QPushButton>
#include <QtGui/QWidget>
class Ui_MainWindow
{
public:
{
.....
label = new QLabel(centralwidget
);
label
->setObjectName
(QString::fromUtf8("label"));
label
->setGeometry
(QRect(60,
100,
46,
14));
.......
retranslateUi(MainWindow);
//QObject::connect(pushButtonOpen, SIGNAL(clicked()), label, SLOT(clear()));
} // setupUi
{
........
Q_UNUSED(MainWindow);
} // retranslateUi
};
namespace Ui {
class MainWindow: public Ui_MainWindow {};
} // namespace Ui
#endif // UI_GUI_H
#ifndef UI_GUI_H
#define UI_GUI_H
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QLabel>
#include <QtGui/QMainWindow>
#include <QtGui/QMenuBar>
#include <QtGui/QPushButton>
#include <QtGui/QWidget>
class Ui_MainWindow
{
public:
QWidget *centralwidget;
QPushButton *pushButtonOpen;
QPushButton *pushButtonClose;
QLabel *label;
QMenuBar *menubar;
void setupUi(QMainWindow *MainWindow)
{
.....
label = new QLabel(centralwidget);
label->setObjectName(QString::fromUtf8("label"));
label->setGeometry(QRect(60, 100, 46, 14));
.......
retranslateUi(MainWindow);
//QObject::connect(pushButtonOpen, SIGNAL(clicked()), label, SLOT(clear()));
QMetaObject::connectSlotsByName(MainWindow);
} // setupUi
void retranslateUi(QMainWindow *MainWindow)
{
........
label->setText(QApplication::translate("MainWindow", "TextLabel", 0, QApplication::UnicodeUTF8));
Q_UNUSED(MainWindow);
} // retranslateUi
};
namespace Ui {
class MainWindow: public Ui_MainWindow {};
} // namespace Ui
#endif // UI_GUI_H
To copy to clipboard, switch view to plain text mode
main.cpp:
#include <QtGui>
#include <QApplication>
#include "ventana.h"
int main(int argc, char *argv[])
{
intervalo = 0;
Ventana widget;
widget.show();
return app.exec();
}
#include <QtGui>
#include <QApplication>
#include "ventana.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
intervalo = 0;
Ventana widget;
widget.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
ventana.h:
#include "ui.h"
class Ventana
: public QMainWindow,
private Ui
::MainWindow{
Q_OBJECT
public:
Ventana();
public slots:
void Bopen();
void Bclose();
};
#include "ui.h"
class Ventana : public QMainWindow, private Ui::MainWindow
{
Q_OBJECT
public:
Ventana();
public slots:
void Bopen();
void Bclose();
};
To copy to clipboard, switch view to plain text mode
ventana.cpp:
#include <QtGui>
#include "ventana.h"
#include "function.h"
Ventana::Ventana()
{
setupUi(this);
connect(pushButtonOpen, SIGNAL(clicked()), this, SLOT(Bopen()));
connect(pushButtonClose, SIGNAL(clicked()), this, SLOT(Bclose()));
}
void Ventana::Bclose(){
label
->setText
(QString("CloseOk"));
functionDoSomething();
}
void Ventana::Bopen(){
}
#include <QtGui>
#include "ventana.h"
#include "function.h"
Ventana::Ventana()
{
setupUi(this);
connect(pushButtonOpen, SIGNAL(clicked()), this, SLOT(Bopen()));
connect(pushButtonClose, SIGNAL(clicked()), this, SLOT(Bclose()));
}
void Ventana::Bclose(){
label->setText(QString("CloseOk"));
functionDoSomething();
}
void Ventana::Bopen(){
label->setText(QString("OpenOK"));
}
To copy to clipboard, switch view to plain text mode
From HERE im call label->setText();
But say is undeclared.
function.cpp:
#include <QtGui>
#include "function.h"
void functionDoSomething(){
//here call to Qlabel
label
->setText
(QString("HELLO WORLD"));
}
#include <QtGui>
#include "function.h"
void functionDoSomething(){
//here call to Qlabel
label->setText(QString("HELLO WORLD"));
}
To copy to clipboard, switch view to plain text mode
function.h:
void functionDoSomething();
void functionDoSomething();
To copy to clipboard, switch view to plain text mode
Bookmarks