#include <QtGui>
#include <QApplication>
{
Q_OBJECT
public:
explicit DockWidget
(const QString &title,
QWidget *parent
= 0, Qt
::WindowFlags flags
= 0) {
connect(pushButton, SIGNAL(clicked()), SLOT(hide()));
groupBox->layout()->addWidget(pushButton);
setWidget(groupBox);
}
};
int main(int argc, char **argv)
{
mainWindow.showMaximized();
{
label
->setFont
(QFont("Arial",
24));
groupBox->layout()->addWidget(label);
mainWindow.setCentralWidget(groupBox);
}
DockWidget * dockWidget = new DockWidget("DockWidget");
mainWindow.addDockWidget(Qt::LeftDockWidgetArea, dockWidget, Qt::Vertical);
return app.exec();
}
#include "main.moc"
#include <QtGui>
#include <QApplication>
class DockWidget : public QDockWidget
{
Q_OBJECT
public:
explicit DockWidget(const QString &title, QWidget *parent = 0, Qt::WindowFlags flags = 0)
: QDockWidget(title, parent, flags)
{
QGroupBox * groupBox = new QGroupBox;
QPushButton * pushButton = new QPushButton("Hide");
connect(pushButton, SIGNAL(clicked()), SLOT(hide()));
groupBox->setLayout(new QGridLayout);
groupBox->layout()->addWidget(pushButton);
setWidget(groupBox);
}
};
int main(int argc, char **argv)
{
QApplication app(argc, argv);
QMainWindow mainWindow;
mainWindow.showMaximized();
{
QGroupBox * groupBox = new QGroupBox;
QLabel * label = new QLabel("Central Widget");
label->setFont(QFont("Arial", 24));
groupBox->setLayout(new QGridLayout);
groupBox->layout()->addWidget(label);
mainWindow.setCentralWidget(groupBox);
}
DockWidget * dockWidget = new DockWidget("DockWidget");
mainWindow.addDockWidget(Qt::LeftDockWidgetArea, dockWidget, Qt::Vertical);
return app.exec();
}
#include "main.moc"
To copy to clipboard, switch view to plain text mode
Bookmarks