一个简单的使用例子如下:
#include "mainwindow.h"
#include <QtGui/QDockWidget>
#include <QtGui/QTextEdit>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
QDockWidget* widget = new QDockWidget(tr("DockWidget"));
QTextEdit* edit = new QTextEdit;
widget->setWidget(edit);
widget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
this->addDockWidget(Qt::LeftDockWidgetArea,widget);
}
MainWindow::~MainWindow()
{
}
需要说明的是仅MainWidow仅可设置Dock