Skip to content

Commit b19cc98

Browse files
Update README.md
1 parent f3f5b66 commit b19cc98

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,68 @@ main window layout.
5858
Open the `ads.pro` with QtCreator and start the build, that's it.
5959
You can run the demo project and test it yourself.
6060

61+
## Getting started / Example
62+
The following example shows the minimum code required to use the advanced Qt docking system.
63+
64+
*MainWindow.h*
65+
66+
```cpp
67+
#include <QMainWindow>
68+
#include "DockManager.h"
69+
70+
namespace Ui {
71+
class MainWindow;
72+
}
73+
74+
class MainWindow : public QMainWindow
75+
{
76+
Q_OBJECT
77+
78+
public:
79+
explicit MainWindow(QWidget *parent = 0);
80+
~MainWindow();
81+
82+
private:
83+
Ui::MainWindow *ui;
84+
85+
// The main container for docking
86+
ads::CDockManager* m_DockManager;
87+
};
88+
```
89+
*MainWindow.cpp*
90+
```cpp
91+
#include "MainWindow.h"
92+
#include "ui_MainWindow.h"
93+
94+
#include <QLabel>
95+
96+
MainWindow::MainWindow(QWidget *parent) :
97+
QMainWindow(parent),
98+
ui(new Ui::MainWindow)
99+
{
100+
ui->setupUi(this);
101+
102+
// Create the dock manager
103+
m_DockManager = new ads::CDockManager(this);
104+
105+
QLabel* l = new QLabel();
106+
l->setWordWrap(true);
107+
l->setAlignment(Qt::AlignTop | Qt::AlignLeft);
108+
l->setText("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. ");
109+
110+
// Create a dock widget with the title Label 1
111+
ads::CDockWidget* DockWidget = new ads::CDockWidget("Label 1");
112+
DockWidget->setWidget(l);
113+
ui->menuView->addAction(DockWidget->toggleViewAction());
114+
m_DockManager->addDockWidget(ads::TopDockWidgetArea, DockWidget);
115+
}
116+
117+
MainWindow::~MainWindow()
118+
{
119+
delete ui;
120+
}
121+
```
122+
61123
## Developers
62124
- Uwe Kindler, Project Maintainer
63125
- Manuel Freiholz

0 commit comments

Comments
 (0)