From 8f54dd2a825a316b4e11ce703e45b67e9dbdc13d Mon Sep 17 00:00:00 2001 From: Uwe Kindler Date: Thu, 20 Dec 2018 09:15:02 +0100 Subject: [PATCH] Added example project and updated documentation --- .cproject | 68 ++++++++++++++++++++++++++++++++---------- README.md | 31 ++++++++++++------- ads.pro | 3 +- demo/demo.pro | 2 +- example/MainWindow.cpp | 39 ++++++++++++++++++++++++ example/MainWindow.h | 24 +++++++++++++++ example/MainWindow.ui | 38 +++++++++++++++++++++++ example/example.pro | 51 +++++++++++++++++++++++++++++++ example/main.cpp | 11 +++++++ 9 files changed, 239 insertions(+), 28 deletions(-) create mode 100644 example/MainWindow.cpp create mode 100644 example/MainWindow.h create mode 100644 example/MainWindow.ui create mode 100644 example/example.pro create mode 100644 example/main.cpp diff --git a/.cproject b/.cproject index 9416104..2463a34 100644 --- a/.cproject +++ b/.cproject @@ -71,6 +71,15 @@ + + + + + + + + + @@ -83,6 +92,7 @@ make + clean false true @@ -99,7 +109,6 @@ qmake -recursive ../ads.pro - true false false @@ -122,7 +131,6 @@ make - clean false true @@ -139,7 +147,6 @@ qmake -recursive ../../src/src.pro - true false false @@ -152,6 +159,46 @@ false false + + mingw32-make + -j + all + false + false + false + + + make + + clean + false + true + false + + + mingw32-make + -j6 + debug + false + false + false + + + qmake + -recursive ../../example/example.pro + + true + false + false + + + mingw32-make + -j4 + release + false + false + false + mingw32-make -j @@ -162,7 +209,6 @@ make - clean false true @@ -179,7 +225,6 @@ qmake -recursive ../../demo/demo.pro - true false false @@ -202,6 +247,7 @@ make + clean false true @@ -240,6 +286,7 @@ make + clean false true @@ -278,6 +325,7 @@ make + clean false true @@ -294,7 +342,6 @@ qmake -recursive ../../AdvancedDockingSystem/src.pro - true false false @@ -309,13 +356,4 @@ - - - - - - - - - diff --git a/README.md b/README.md index 567d445..c24f440 100644 --- a/README.md +++ b/README.md @@ -99,19 +99,28 @@ MainWindow::MainWindow(QWidget *parent) : { ui->setupUi(this); - // Create the dock manager - m_DockManager = new ads::CDockManager(this); + // Create the dock manager. Because the parent parameter is a QMainWindow + // the dock manager registers itself as the central widget. + m_DockManager = new ads::CDockManager(this); - QLabel* l = new QLabel(); - l->setWordWrap(true); - l->setAlignment(Qt::AlignTop | Qt::AlignLeft); - l->setText("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. "); + // Create example content label - this can be any application specific + // widget + QLabel* l = new QLabel(); + l->setWordWrap(true); + l->setAlignment(Qt::AlignTop | Qt::AlignLeft); + l->setText("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. "); - // Create a dock widget with the title Label 1 - ads::CDockWidget* DockWidget = new ads::CDockWidget("Label 1"); - DockWidget->setWidget(l); - ui->menuView->addAction(DockWidget->toggleViewAction()); - m_DockManager->addDockWidget(ads::TopDockWidgetArea, DockWidget); + // Create a dock widget with the title Label 1 and set the created label + // as the dock widget content + ads::CDockWidget* DockWidget = new ads::CDockWidget("Label 1"); + DockWidget->setWidget(l); + + // Add the toggleViewAction of the dock widget to the menu to give + // the user the possibility to show the dock widget if it has been closed + ui->menuView->addAction(DockWidget->toggleViewAction()); + + // Add the dock widget to the top dock widget area + m_DockManager->addDockWidget(ads::TopDockWidgetArea, DockWidget); } MainWindow::~MainWindow() diff --git a/ads.pro b/ads.pro index 4b1c31a..63d1887 100644 --- a/ads.pro +++ b/ads.pro @@ -3,4 +3,5 @@ CONFIG += ordered SUBDIRS = \ src \ - demo + demo \ + example diff --git a/demo/demo.pro b/demo/demo.pro index 36dd637..73086c9 100644 --- a/demo/demo.pro +++ b/demo/demo.pro @@ -25,7 +25,7 @@ LIBS += -L$${ADS_OUT_ROOT}/lib # Dependency: AdvancedDockingSystem (shared) win32:CONFIG(release, debug|release): LIBS += -lqtadvanceddocking else:win32:CONFIG(debug, debug|release): LIBS += -lqtadvanceddockingd -else:unix: LIBS += -lAdvancedDockingSystem +else:unix: LIBS += -lqtadvanceddocking INCLUDEPATH += ../src DEPENDPATH += ../src diff --git a/example/MainWindow.cpp b/example/MainWindow.cpp new file mode 100644 index 0000000..f9edab0 --- /dev/null +++ b/example/MainWindow.cpp @@ -0,0 +1,39 @@ +#include "MainWindow.h" +#include "ui_MainWindow.h" + +#include + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); + + // Create the dock manager. Because the parent parameter is a QMainWindow + // the dock manager registers itself as the central widget. + m_DockManager = new ads::CDockManager(this); + + // Create example content label - this can be any application specific + // widget + QLabel* l = new QLabel(); + l->setWordWrap(true); + l->setAlignment(Qt::AlignTop | Qt::AlignLeft); + l->setText("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. "); + + // Create a dock widget with the title Label 1 and set the created label + // as the dock widget content + ads::CDockWidget* DockWidget = new ads::CDockWidget("Label 1"); + DockWidget->setWidget(l); + + // Add the toggleViewAction of the dock widget to the menu to give + // the user the possibility to show the dock widget if it has been closed + ui->menuView->addAction(DockWidget->toggleViewAction()); + + // Add the dock widget to the top dock widget area + m_DockManager->addDockWidget(ads::TopDockWidgetArea, DockWidget); +} + +MainWindow::~MainWindow() +{ + delete ui; +} diff --git a/example/MainWindow.h b/example/MainWindow.h new file mode 100644 index 0000000..462d4f6 --- /dev/null +++ b/example/MainWindow.h @@ -0,0 +1,24 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include +#include "DockManager.h" + +namespace Ui { +class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = 0); + ~MainWindow(); + +private: + Ui::MainWindow *ui; + ads::CDockManager* m_DockManager; +}; + +#endif // MAINWINDOW_H diff --git a/example/MainWindow.ui b/example/MainWindow.ui new file mode 100644 index 0000000..c8cdb8e --- /dev/null +++ b/example/MainWindow.ui @@ -0,0 +1,38 @@ + + + MainWindow + + + + 0 + 0 + 400 + 300 + + + + MainWindow + + + + + + 0 + 0 + 400 + 21 + + + + + View + + + + + + + + + + diff --git a/example/example.pro b/example/example.pro new file mode 100644 index 0000000..e571329 --- /dev/null +++ b/example/example.pro @@ -0,0 +1,51 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2018-12-14T22:42:14 +# +#------------------------------------------------- +ADS_ROOT = $${PWD}/.. +ADS_OUT_ROOT = $${OUT_PWD}/.. + +QT += core gui widgets + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = Example1 +DESTDIR = $${ADS_OUT_ROOT}/lib +TEMPLATE = app +CONFIG *= c++14 + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which has been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + + +SOURCES += \ + main.cpp \ + MainWindow.cpp + +HEADERS += \ + MainWindow.h + +FORMS += \ + MainWindow.ui + +#RESOURCES += main.qrc + +LIBS += -L$${ADS_OUT_ROOT}/lib + +# Dependency: AdvancedDockingSystem (shared) +win32:CONFIG(release, debug|release): LIBS += -lqtadvanceddocking +else:win32:CONFIG(debug, debug|release): LIBS += -lqtadvanceddockingd +else:unix: LIBS += -lqtadvanceddocking + +INCLUDEPATH += ../src +DEPENDPATH += ../src + diff --git a/example/main.cpp b/example/main.cpp new file mode 100644 index 0000000..af9caac --- /dev/null +++ b/example/main.cpp @@ -0,0 +1,11 @@ +#include "MainWindow.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + + return a.exec(); +}