Sorry. Here we go...
main.cpp
#include <QApplication>
#include "mainwindow.h"
int main(int argc, char *argv[])
{
MainWindow *dialog = new MainWindow;
dialog->show();
return app.exec();
}
#include <QApplication>
#include "mainwindow.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
MainWindow *dialog = new MainWindow;
dialog->show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
mainwindow.cpp
#include "mainwindow.h"
#include <QtGui>
#include <QPixmap>
MainWindow
::MainWindow(QWidget *parent
){
setupUi(this);
connect( pushButton_display, SIGNAL( clicked() ), this, SLOT( display_pic() ) );
}
void MainWindow::display_pic()
{
label_image->setPixmap(pixmap);
}
#include "mainwindow.h"
#include <QtGui>
#include <QPixmap>
MainWindow::MainWindow(QWidget *parent)
{
setupUi(this);
connect( pushButton_display, SIGNAL( clicked() ), this, SLOT( display_pic() ) );
}
void MainWindow::display_pic()
{
QPixmap pixmap("Dima.jpg");
label_image->setPixmap(pixmap);
}
To copy to clipboard, switch view to plain text mode
mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QWidget>
#include "ui_mainwindow.h"
class MainWindow
: public QWidget,
private Ui
::MainWindowDLG{
Q_OBJECT
public:
public slots:
void display_pic();
};
#endif
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QWidget>
#include "ui_mainwindow.h"
class MainWindow : public QWidget, private Ui::MainWindowDLG
{
Q_OBJECT
public:
MainWindow(QWidget *parent = 0);
public slots:
void display_pic();
};
#endif
To copy to clipboard, switch view to plain text mode
ui_mainwindow.h
/********************************************************************************
** Form generated from reading ui file 'mainwindow.ui'
**
** Created: Mon Jun 15 22:04:49 2009
** by: Qt User Interface Compiler version 4.5.1
**
** WARNING! All changes made in this file will be lost when recompiling ui file!
********************************************************************************/
#ifndef UI_MAINWINDOW_H
#define UI_MAINWINDOW_H
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QHeaderView>
#include <QtGui/QLabel>
#include <QtGui/QMainWindow>
#include <QtGui/QPushButton>
#include <QtGui/QWidget>
QT_BEGIN_NAMESPACE
class Ui_MainWindow
{
public:
{
if (MainWindow->objectName().isEmpty())
MainWindow
->setObjectName
(QString::fromUtf8("MainWindow"));
MainWindow->resize(770, 524);
MainWindow
->setStyleSheet
(QString::fromUtf8("background-color: rgb(136, 162, 255);\n"""));
centralWidget
= new QWidget(MainWindow
);
centralWidget
->setObjectName
(QString::fromUtf8("centralWidget"));
label_image
= new QLabel(centralWidget
);
label_image
->setObjectName
(QString::fromUtf8("label_image"));
label_image
->setGeometry
(QRect(10,
10,
751,
461));
label_image
->setStyleSheet
(QString::fromUtf8("background-color: rgba(62, 99, 255, 43);"));
pushButton_display
->setObjectName
(QString::fromUtf8("pushButton_display"));
pushButton_display
->setGeometry
(QRect(330,
480,
113,
32));
MainWindow->setCentralWidget(centralWidget);
retranslateUi(MainWindow);
} // setupUi
{
Q_UNUSED(MainWindow);
} // retranslateUi
};
namespace Ui {
class MainWindow: public Ui_MainWindow {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_MAINWINDOW_H
/********************************************************************************
** Form generated from reading ui file 'mainwindow.ui'
**
** Created: Mon Jun 15 22:04:49 2009
** by: Qt User Interface Compiler version 4.5.1
**
** WARNING! All changes made in this file will be lost when recompiling ui file!
********************************************************************************/
#ifndef UI_MAINWINDOW_H
#define UI_MAINWINDOW_H
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QHeaderView>
#include <QtGui/QLabel>
#include <QtGui/QMainWindow>
#include <QtGui/QPushButton>
#include <QtGui/QWidget>
QT_BEGIN_NAMESPACE
class Ui_MainWindow
{
public:
QWidget *centralWidget;
QLabel *label_image;
QPushButton *pushButton_display;
void setupUi(QMainWindow *MainWindow)
{
if (MainWindow->objectName().isEmpty())
MainWindow->setObjectName(QString::fromUtf8("MainWindow"));
MainWindow->resize(770, 524);
MainWindow->setStyleSheet(QString::fromUtf8("background-color: rgb(136, 162, 255);\n"
""));
centralWidget = new QWidget(MainWindow);
centralWidget->setObjectName(QString::fromUtf8("centralWidget"));
label_image = new QLabel(centralWidget);
label_image->setObjectName(QString::fromUtf8("label_image"));
label_image->setGeometry(QRect(10, 10, 751, 461));
label_image->setStyleSheet(QString::fromUtf8("background-color: rgba(62, 99, 255, 43);"));
pushButton_display = new QPushButton(centralWidget);
pushButton_display->setObjectName(QString::fromUtf8("pushButton_display"));
pushButton_display->setGeometry(QRect(330, 480, 113, 32));
MainWindow->setCentralWidget(centralWidget);
retranslateUi(MainWindow);
QMetaObject::connectSlotsByName(MainWindow);
} // setupUi
void retranslateUi(QMainWindow *MainWindow)
{
MainWindow->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", 0, QApplication::UnicodeUTF8));
label_image->setText(QString());
pushButton_display->setText(QApplication::translate("MainWindow", "Push Me", 0, QApplication::UnicodeUTF8));
Q_UNUSED(MainWindow);
} // retranslateUi
};
namespace Ui {
class MainWindow: public Ui_MainWindow {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_MAINWINDOW_H
To copy to clipboard, switch view to plain text mode
Bookmarks