Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
582 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#------------------------------------------------- | ||
# | ||
# Project created by QtCreator 2011-07-21T09:10:01 | ||
# | ||
#------------------------------------------------- | ||
|
||
QT += core gui | ||
|
||
TARGET = Lab_Dialogs | ||
TEMPLATE = app | ||
|
||
|
||
SOURCES += main.cpp\ | ||
mainwindow.cpp \ | ||
dialog.cpp | ||
|
||
HEADERS += mainwindow.h \ | ||
dialog.h | ||
|
||
FORMS += mainwindow.ui \ | ||
dialog.ui |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include "dialog.h" | ||
#include "ui_dialog.h" | ||
#include <QMessageBox> | ||
|
||
Dialog::Dialog(int val, QWidget *parent) : | ||
QDialog(parent), | ||
ui(new Ui::Dialog) | ||
{ | ||
ui->setupUi(this); | ||
|
||
QObject::connect(ui->buttonBox, SIGNAL(rejected()), | ||
this, SLOT(reject())); | ||
|
||
QObject::connect(ui->buttonBox, SIGNAL(accepted()), | ||
this, SLOT(validate())); | ||
|
||
ui->spinBox->setValue(val); | ||
} | ||
|
||
Dialog::~Dialog() | ||
{ | ||
delete ui; | ||
} | ||
|
||
void Dialog::validate() | ||
{ | ||
int val = value(); | ||
|
||
if ( val < 50 ) | ||
{ | ||
accept(); | ||
return; | ||
} | ||
else | ||
{ | ||
QMessageBox::warning(this, tr("Value too high"), | ||
tr("Please type a value < 50")); | ||
|
||
} | ||
} | ||
|
||
int Dialog::value() | ||
{ | ||
return ui->spinBox->value(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#ifndef DIALOG_H | ||
#define DIALOG_H | ||
|
||
#include <QDialog> | ||
|
||
namespace Ui { | ||
class Dialog; | ||
} | ||
|
||
class Dialog : public QDialog | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit Dialog(int val, QWidget *parent = 0); | ||
~Dialog(); | ||
|
||
int value(); | ||
private slots: | ||
void validate(); | ||
|
||
private: | ||
Ui::Dialog *ui; | ||
}; | ||
|
||
#endif // DIALOG_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>Dialog</class> | ||
<widget class="QDialog" name="Dialog"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>400</width> | ||
<height>300</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>Dialog</string> | ||
</property> | ||
<layout class="QVBoxLayout" name="verticalLayout"> | ||
<item> | ||
<widget class="QSpinBox" name="spinBox"/> | ||
</item> | ||
<item> | ||
<widget class="QSlider" name="horizontalSlider"> | ||
<property name="orientation"> | ||
<enum>Qt::Horizontal</enum> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QDialogButtonBox" name="buttonBox"> | ||
<property name="standardButtons"> | ||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</widget> | ||
<resources/> | ||
<connections> | ||
<connection> | ||
<sender>horizontalSlider</sender> | ||
<signal>valueChanged(int)</signal> | ||
<receiver>spinBox</receiver> | ||
<slot>setValue(int)</slot> | ||
<hints> | ||
<hint type="sourcelabel"> | ||
<x>53</x> | ||
<y>146</y> | ||
</hint> | ||
<hint type="destinationlabel"> | ||
<x>83</x> | ||
<y>70</y> | ||
</hint> | ||
</hints> | ||
</connection> | ||
<connection> | ||
<sender>spinBox</sender> | ||
<signal>valueChanged(int)</signal> | ||
<receiver>horizontalSlider</receiver> | ||
<slot>setValue(int)</slot> | ||
<hints> | ||
<hint type="sourcelabel"> | ||
<x>215</x> | ||
<y>66</y> | ||
</hint> | ||
<hint type="destinationlabel"> | ||
<x>226</x> | ||
<y>144</y> | ||
</hint> | ||
</hints> | ||
</connection> | ||
</connections> | ||
</ui> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include <QtGui/QApplication> | ||
#include "mainwindow.h" | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
QApplication a(argc, argv); | ||
MainWindow w; | ||
w.show(); | ||
|
||
return a.exec(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#include "mainwindow.h" | ||
#include "ui_mainwindow.h" | ||
#include "dialog.h" | ||
|
||
MainWindow::MainWindow(QWidget *parent) : | ||
QMainWindow(parent), | ||
ui(new Ui::MainWindow) | ||
{ | ||
ui->setupUi(this); | ||
|
||
} | ||
|
||
MainWindow::~MainWindow() | ||
{ | ||
delete ui; | ||
} | ||
|
||
void MainWindow::on_pushButton_clicked() | ||
{ | ||
Dialog d(ui->horizontalSlider->value()); | ||
if ( d.exec() == QDialog::Accepted ) | ||
{ | ||
ui->horizontalSlider->setValue(d.value()); | ||
} | ||
} | ||
|
||
void MainWindow::on_pushButton_2_clicked() | ||
{ | ||
Dialog *d = new Dialog(ui->horizontalSlider->value(), this); | ||
d->show(); | ||
d->raise(); | ||
d->activateWindow(); | ||
|
||
QObject::connect(d, SIGNAL(accepted()), | ||
this, SLOT(dialogAccepted())); | ||
QObject::connect(d, SIGNAL(rejected()), | ||
this, SLOT(dialogRejected())); | ||
} | ||
|
||
void MainWindow::dialogAccepted() | ||
{ | ||
Dialog *d = qobject_cast<Dialog *>(sender()); | ||
|
||
if ( ! d ) | ||
{ | ||
return; | ||
} | ||
|
||
int val = d->value(); | ||
ui->horizontalSlider->setValue(val); | ||
d->deleteLater(); | ||
} | ||
|
||
void MainWindow::dialogRejected() | ||
{ | ||
Dialog *d = qobject_cast<Dialog *>(sender()); | ||
if ( ! d ) | ||
{ | ||
return; | ||
} | ||
|
||
d->deleteLater(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#ifndef MAINWINDOW_H | ||
#define MAINWINDOW_H | ||
|
||
#include <QMainWindow> | ||
|
||
namespace Ui { | ||
class MainWindow; | ||
} | ||
|
||
class MainWindow : public QMainWindow | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit MainWindow(QWidget *parent = 0); | ||
~MainWindow(); | ||
|
||
private slots: | ||
void on_pushButton_clicked(); | ||
|
||
void on_pushButton_2_clicked(); | ||
|
||
void dialogAccepted(); | ||
void dialogRejected(); | ||
|
||
private: | ||
Ui::MainWindow *ui; | ||
}; | ||
|
||
#endif // MAINWINDOW_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>MainWindow</class> | ||
<widget class="QMainWindow" name="MainWindow"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>400</width> | ||
<height>300</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>MainWindow</string> | ||
</property> | ||
<widget class="QWidget" name="centralWidget"> | ||
<layout class="QVBoxLayout" name="verticalLayout"> | ||
<item> | ||
<widget class="QSlider" name="horizontalSlider"> | ||
<property name="orientation"> | ||
<enum>Qt::Horizontal</enum> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<layout class="QHBoxLayout" name="horizontalLayout"> | ||
<item> | ||
<widget class="QPushButton" name="pushButton"> | ||
<property name="text"> | ||
<string>Modal</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QPushButton" name="pushButton_2"> | ||
<property name="text"> | ||
<string>Modeless</string> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</item> | ||
</layout> | ||
</widget> | ||
<widget class="QMenuBar" name="menuBar"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>400</width> | ||
<height>22</height> | ||
</rect> | ||
</property> | ||
</widget> | ||
<widget class="QToolBar" name="mainToolBar"> | ||
<attribute name="toolBarArea"> | ||
<enum>TopToolBarArea</enum> | ||
</attribute> | ||
<attribute name="toolBarBreak"> | ||
<bool>false</bool> | ||
</attribute> | ||
</widget> | ||
<widget class="QStatusBar" name="statusBar"/> | ||
</widget> | ||
<layoutdefault spacing="6" margin="11"/> | ||
<resources/> | ||
<connections/> | ||
</ui> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<RCC> | ||
<qresource prefix="/"> | ||
<file>img/LogoZone-60970253142601.JPG</file> | ||
<file>img/Close Icon.jpg</file> | ||
<file alias="foo">img/Close Icon.jpg</file> | ||
</qresource> | ||
</RCC> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
SOURCES += \ | ||
main.cpp \ | ||
dialog.cpp \ | ||
dialoglauncher.cpp | ||
|
||
HEADERS += \ | ||
dialog.h \ | ||
dialoglauncher.h | ||
|
||
FORMS += \ | ||
dialog.ui |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include "dialog.h" | ||
#include "ui_dialog.h" | ||
|
||
Dialog::Dialog(QWidget *parent) : | ||
QDialog(parent), | ||
ui(new Ui::Dialog) | ||
{ | ||
ui->setupUi(this); | ||
|
||
QObject::connect(ui->buttonBox, SIGNAL(accepted()), | ||
this, SLOT(accept())); | ||
|
||
QObject::connect(ui->buttonBox, SIGNAL(rejected()), | ||
this, SLOT(reject())); | ||
} | ||
|
||
Dialog::~Dialog() | ||
{ | ||
delete ui; | ||
} |
Oops, something went wrong.