From 616e50c3f5e7bfcf5edcd4712de2b4247cb65bfe Mon Sep 17 00:00:00 2001 From: Uwe Kindler Date: Fri, 10 Jan 2020 08:54:44 +0100 Subject: [PATCH] Fixed FloatingDockContainer closeEvent to properly support QAxWidgets --- demo/MainWindow.cpp | 17 ++++++++++++++++- demo/demo.pro | 2 +- src/FloatingDockContainer.cpp | 14 +------------- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/demo/MainWindow.cpp b/demo/MainWindow.cpp index 9e026e6..10f3317 100644 --- a/demo/MainWindow.cpp +++ b/demo/MainWindow.cpp @@ -53,6 +53,7 @@ #include #include #include +#include #include #include @@ -200,6 +201,18 @@ static ads::CDockWidget* createTableWidget(QMenu* ViewMenu) } +//============================================================================ +static ads::CDockWidget* createActiveXWidget(QMenu* ViewMenu, QWidget* parent = nullptr) +{ + static int ActiveXCount = 0; + QAxWidget* w = new QAxWidget("{6bf52a52-394a-11d3-b153-00c04f79faa6}", parent); + ads::CDockWidget* DockWidget = new ads::CDockWidget(QString("Active X %1").arg(ActiveXCount++)); + DockWidget->setWidget(w); + ViewMenu->addAction(DockWidget->toggleViewAction()); + return DockWidget; +} + + //============================================================================ /** * Private data class pimpl @@ -285,6 +298,8 @@ void MainWindowPrivate::createContent() auto Action = ui.menuView->addAction(QString("Set %1 floating").arg(DockWidget->windowTitle())); DockWidget->connect(Action, SIGNAL(triggered()), SLOT(setFloating())); + DockManager->addDockWidgetFloating(createActiveXWidget(ViewMenu)); + for (auto DockWidget : DockManager->dockWidgetsMap()) { _this->connect(DockWidget, SIGNAL(viewToggled(bool)), SLOT(onViewToggled(bool))); @@ -384,7 +399,7 @@ CMainWindow::CMainWindow(QWidget *parent) : // uncomment the following line if you want to use non opaque undocking and splitter // movements - // CDockManager::setConfigFlags(CDockManager::DefaultNonOpaqueConfig); + CDockManager::setConfigFlags(CDockManager::DefaultNonOpaqueConfig); // Now create the dock manager and its content d->DockManager = new CDockManager(this); diff --git a/demo/demo.pro b/demo/demo.pro index e1ece66..aeba607 100644 --- a/demo/demo.pro +++ b/demo/demo.pro @@ -2,7 +2,7 @@ ADS_OUT_ROOT = $${OUT_PWD}/.. TARGET = AdvancedDockingSystemDemo DESTDIR = $${ADS_OUT_ROOT}/lib -QT += core gui widgets +QT += core gui widgets axcontainer CONFIG += c++14 CONFIG += debug_and_release DEFINES += QT_DEPRECATED_WARNINGS diff --git a/src/FloatingDockContainer.cpp b/src/FloatingDockContainer.cpp index 5454fd4..07c29d5 100644 --- a/src/FloatingDockContainer.cpp +++ b/src/FloatingDockContainer.cpp @@ -352,6 +352,7 @@ void CFloatingDockContainer::closeEvent(QCloseEvent *event) { ADS_PRINT("CFloatingDockContainer closeEvent"); d->setState(DraggingInactive); + event->ignore(); if (isClosable()) { @@ -371,20 +372,7 @@ void CFloatingDockContainer::closeEvent(QCloseEvent *event) // Starting from Qt version 5.12.2 this seems to work again. But // now the QEvent::NonClientAreaMouseButtonPress function returns always // Qt::RightButton even if the left button was pressed -#ifndef Q_OS_LINUX -#if (QT_VERSION > QT_VERSION_CHECK(5, 9, 2) && QT_VERSION < QT_VERSION_CHECK(5, 12, 2)) - event->ignore(); this->hide(); -#else - Super::closeEvent(event); -#endif -#else // Q_OS_LINUX - Super::closeEvent(event); -#endif - } - else - { - event->ignore(); } }