Skip to content

Commit 616e50c

Browse files
Fixed FloatingDockContainer closeEvent to properly support QAxWidgets
1 parent 1de42a9 commit 616e50c

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

demo/MainWindow.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
#include <QRubberBand>
5454
#include <QPlainTextEdit>
5555
#include <QTableWidget>
56+
#include <QAxWidget>
5657

5758
#include <QMap>
5859
#include <QElapsedTimer>
@@ -200,6 +201,18 @@ static ads::CDockWidget* createTableWidget(QMenu* ViewMenu)
200201
}
201202

202203

204+
//============================================================================
205+
static ads::CDockWidget* createActiveXWidget(QMenu* ViewMenu, QWidget* parent = nullptr)
206+
{
207+
static int ActiveXCount = 0;
208+
QAxWidget* w = new QAxWidget("{6bf52a52-394a-11d3-b153-00c04f79faa6}", parent);
209+
ads::CDockWidget* DockWidget = new ads::CDockWidget(QString("Active X %1").arg(ActiveXCount++));
210+
DockWidget->setWidget(w);
211+
ViewMenu->addAction(DockWidget->toggleViewAction());
212+
return DockWidget;
213+
}
214+
215+
203216
//============================================================================
204217
/**
205218
* Private data class pimpl
@@ -285,6 +298,8 @@ void MainWindowPrivate::createContent()
285298
auto Action = ui.menuView->addAction(QString("Set %1 floating").arg(DockWidget->windowTitle()));
286299
DockWidget->connect(Action, SIGNAL(triggered()), SLOT(setFloating()));
287300

301+
DockManager->addDockWidgetFloating(createActiveXWidget(ViewMenu));
302+
288303
for (auto DockWidget : DockManager->dockWidgetsMap())
289304
{
290305
_this->connect(DockWidget, SIGNAL(viewToggled(bool)), SLOT(onViewToggled(bool)));
@@ -384,7 +399,7 @@ CMainWindow::CMainWindow(QWidget *parent) :
384399

385400
// uncomment the following line if you want to use non opaque undocking and splitter
386401
// movements
387-
// CDockManager::setConfigFlags(CDockManager::DefaultNonOpaqueConfig);
402+
CDockManager::setConfigFlags(CDockManager::DefaultNonOpaqueConfig);
388403

389404
// Now create the dock manager and its content
390405
d->DockManager = new CDockManager(this);

demo/demo.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ ADS_OUT_ROOT = $${OUT_PWD}/..
22

33
TARGET = AdvancedDockingSystemDemo
44
DESTDIR = $${ADS_OUT_ROOT}/lib
5-
QT += core gui widgets
5+
QT += core gui widgets axcontainer
66
CONFIG += c++14
77
CONFIG += debug_and_release
88
DEFINES += QT_DEPRECATED_WARNINGS

src/FloatingDockContainer.cpp

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ void CFloatingDockContainer::closeEvent(QCloseEvent *event)
352352
{
353353
ADS_PRINT("CFloatingDockContainer closeEvent");
354354
d->setState(DraggingInactive);
355+
event->ignore();
355356

356357
if (isClosable())
357358
{
@@ -371,20 +372,7 @@ void CFloatingDockContainer::closeEvent(QCloseEvent *event)
371372
// Starting from Qt version 5.12.2 this seems to work again. But
372373
// now the QEvent::NonClientAreaMouseButtonPress function returns always
373374
// Qt::RightButton even if the left button was pressed
374-
#ifndef Q_OS_LINUX
375-
#if (QT_VERSION > QT_VERSION_CHECK(5, 9, 2) && QT_VERSION < QT_VERSION_CHECK(5, 12, 2))
376-
event->ignore();
377375
this->hide();
378-
#else
379-
Super::closeEvent(event);
380-
#endif
381-
#else // Q_OS_LINUX
382-
Super::closeEvent(event);
383-
#endif
384-
}
385-
else
386-
{
387-
event->ignore();
388376
}
389377
}
390378

0 commit comments

Comments
 (0)