Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindowClass)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void showDialog()
{
// whistling in the dark
}
|
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 |
#include <QtGui/QApplication>
#include "mainwindow.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
|
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QtGui/QMainWindow>
namespace Ui
{
class MainWindowClass;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = 0);
~MainWindow();
public slots;
void showDialog();
private:
Ui::MainWindowClass *ui;
};
#endif // MAINWINDOW_H
|
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "ui_dialog.h"
#include <QtGui>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindowClass)
{
ui->setupUi(this);
connect(ui->actionOptions, SIGNAL(triggered() ), this, SLOT( showOptionsDialog() ) );
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::showOptionsDialog()
{
//The code below shows a blank dialog
//How do I show the dialog window from my file, dialog.ui, instead?
QDialog optionsDialog(this);
optionsDialog.setWindowTitle(tr("Configure Options"));
optionsDialog.exec();
}
void MainWindow::acceptOptionsChanges()
{
//ACTION: Write the changes to config file if the user clicks OK
QSettings settings("/options.ini",
QSettings::IniFormat);
settings.setValue("testKey", "testValue");
}
|
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QtGui/QMainWindow>
namespace Ui
{
class MainWindowClass;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = 0);
~MainWindow();
public slots:
void showOptionsDialog();
void acceptOptionsChanges();
private:
Ui::MainWindowClass *ui;
};
#endif // MAINWINDOW_H
|
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 |
#include <QtGui/QApplication>
#include "mainwindow.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
|
|
|
Source code |
1 2 3 4 5 6 7 8 |
#include "mainwindow.h"
#include "ui_mainwindow.h" // <<<<<<<< ui design file
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindowClass)
{
ui->setupUi(this); // <<<<<<<<<< setup the ui.
}
|