ApplicationWindow
::ApplicationWindow(QWidget* parent
) : QMainWindow(parent, Qt
::WindowTitleHint | Qt
::WindowMinimizeButtonHint | Qt
::WindowSystemMenuHint){
setWindowTitle(tr("QTApp"));
setMinimumSize(400, 150);
createActions();
createMenus();
types << "Executable Files (*.exe)" << "Any files (*)";
fileDialog->setWindowTitle(tr("Select a program"));
fileDialog->setFilters(types);
exepathEdit
= new QLineEdit(groupBoxOptions
);
cmdlineEdit
= new QLineEdit(groupBoxOptions
);
buttonSelectFile
= new QPushButton(tr
("Select..."), groupBoxOptions
);
connect(buttonSelectFile, SIGNAL(clicked()), this, SLOT(selectFile()));
layoutOptions
->addWidget
(new QLabel(tr
("Exepath:")),
1,
1);
layoutOptions->addWidget(exepathEdit, 1, 2);
layoutOptions->addWidget(buttonSelectFile, 1, 3);
layoutOptions
->addWidget
(new QLabel(tr
("Cmdline:")),
2,
1);
layoutOptions->addWidget(cmdlineEdit, 2, 2, 1, 2);
layoutOptions->setColumnStretch(1, 20);
layoutOptions->setColumnStretch(2, 60);
layoutOptions->setColumnStretch(3, 20);
groupBoxOptions->setLayout(layoutOptions);
dock->setAllowedAreas(Qt::BottomDockWidgetArea);
textEdit->setReadOnly(true);
textEdit->setFixedHeight(100);
dock->setWidget(textEdit);
addDockWidget(Qt::BottomDockWidgetArea, dock);
viewMenu->addAction(dock->toggleViewAction());
connect(dock, SIGNAL(visibilityChanged(bool)), this, SLOT(adjust()));
buttonStart->setDefault(true);
connect(buttonStart, SIGNAL(clicked()), this, SLOT(start()));
buttonLayout->addStretch(1);
buttonLayout->addWidget(buttonStart);
buttonLayout->addStretch(1);
centerLayout->addWidget(groupBoxOptions);
centerLayout->addLayout(buttonLayout);
center->setLayout(centerLayout);
setCentralWidget(center);
}
void ApplicationWindow::adjust()
{
adjustSize();
}
ApplicationWindow::ApplicationWindow(QWidget* parent) : QMainWindow(parent, Qt::WindowTitleHint | Qt::WindowMinimizeButtonHint | Qt::WindowSystemMenuHint)
{
setWindowTitle(tr("QTApp"));
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
setMinimumSize(400, 150);
createActions();
createMenus();
center = new QWidget(this);
center->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
QStringList types;
types << "Executable Files (*.exe)" << "Any files (*)";
fileDialog = new QFileDialog(this);
fileDialog->setWindowTitle(tr("Select a program"));
fileDialog->setAcceptMode(QFileDialog::AcceptOpen);
fileDialog->setFilters(types);
QGroupBox *groupBoxOptions = new QGroupBox(tr("Options"), center);
QGridLayout *layoutOptions = new QGridLayout(groupBoxOptions);
exepathEdit = new QLineEdit(groupBoxOptions);
cmdlineEdit = new QLineEdit(groupBoxOptions);
buttonSelectFile = new QPushButton(tr("Select..."), groupBoxOptions);
connect(buttonSelectFile, SIGNAL(clicked()), this, SLOT(selectFile()));
layoutOptions->addWidget(new QLabel(tr("Exepath:")), 1, 1);
layoutOptions->addWidget(exepathEdit, 1, 2);
layoutOptions->addWidget(buttonSelectFile, 1, 3);
layoutOptions->addWidget(new QLabel(tr("Cmdline:")), 2, 1);
layoutOptions->addWidget(cmdlineEdit, 2, 2, 1, 2);
layoutOptions->setColumnStretch(1, 20);
layoutOptions->setColumnStretch(2, 60);
layoutOptions->setColumnStretch(3, 20);
groupBoxOptions->setLayout(layoutOptions);
dock = new QDockWidget(tr("Output"), this);
dock->setAllowedAreas(Qt::BottomDockWidgetArea);
dock->setFeatures(QDockWidget::DockWidgetClosable);
textEdit = new QTextEdit(dock);
textEdit->setReadOnly(true);
textEdit->setFixedHeight(100);
dock->setWidget(textEdit);
addDockWidget(Qt::BottomDockWidgetArea, dock);
viewMenu->addAction(dock->toggleViewAction());
connect(dock, SIGNAL(visibilityChanged(bool)), this, SLOT(adjust()));
buttonStart = new QPushButton(tr("Start"));
buttonStart->setDefault(true);
connect(buttonStart, SIGNAL(clicked()), this, SLOT(start()));
QHBoxLayout *buttonLayout = new QHBoxLayout;
buttonLayout->addStretch(1);
buttonLayout->addWidget(buttonStart);
buttonLayout->addStretch(1);
QVBoxLayout *centerLayout = new QVBoxLayout;
centerLayout->addWidget(groupBoxOptions);
centerLayout->addLayout(buttonLayout);
center->setLayout(centerLayout);
setCentralWidget(center);
}
void ApplicationWindow::adjust()
{
adjustSize();
}
To copy to clipboard, switch view to plain text mode
Without Dock:
____________________
|Main |
|--------------------|
| .-Options---------.|
| | Exe: [Blablub ] ||
| | Cmd: [Blablub ] ||
| |_________________||
| [Start] |
|____________________|
With dock:
____________________
|Main |
|--------------------|
| .-Options---------.|
| | Exe: [Blablub ] ||
| | Cmd: [Blablub ] ||
| |_________________||
| [Start] |
|--------------------|
|Output x|
| .-----------------.|
| |Blablub... ||
| |Blablub... ||
| | ||
| |_________________||
|____________________|
Without Dock:
____________________
|Main |
|--------------------|
| .-Options---------.|
| | Exe: [Blablub ] ||
| | Cmd: [Blablub ] ||
| |_________________||
| [Start] |
|____________________|
With dock:
____________________
|Main |
|--------------------|
| .-Options---------.|
| | Exe: [Blablub ] ||
| | Cmd: [Blablub ] ||
| |_________________||
| [Start] |
|--------------------|
|Output x|
| .-----------------.|
| |Blablub... ||
| |Blablub... ||
| | ||
| |_________________||
|____________________|
To copy to clipboard, switch view to plain text mode
It doesn't have to be a dock, if anyone knows a custom widget that allows you to do something like this, I would appreciate if you point me to it.
Bookmarks