qtquick: DockWidget now receives QQmlEngine as param

If nullptr then the usual Config::qmlEngine() will be used.
This commit is contained in:
Sergio Martins
2021-07-04 18:41:52 +01:00
parent 54233085a4
commit 238193f56b
3 changed files with 10 additions and 4 deletions

View File

@@ -48,9 +48,10 @@ public:
QQmlEngine *const m_qmlEngine;
};
DockWidgetQuick::DockWidgetQuick(const QString &name, Options options, LayoutSaverOptions layoutSaverOptions)
DockWidgetQuick::DockWidgetQuick(const QString &name, Options options,
LayoutSaverOptions layoutSaverOptions, QQmlEngine *engine)
: DockWidgetBase(name, options, layoutSaverOptions)
, d(new Private(this, Config::self().qmlEngine()))
, d(new Private(this, engine ? engine : Config::self().qmlEngine()))
{
// To mimic what QtWidgets does when creating a new QWidget.
setVisible(false);

View File

@@ -23,6 +23,7 @@
QT_BEGIN_NAMESPACE
class QCloseEvent;
class QQmlEngine;
QT_END_NAMESPACE
namespace KDDockWidgets {
@@ -44,12 +45,16 @@ public:
* @brief constructs a new DockWidget
* @param uniqueName the name of the dockwidget, should be unique. Use title for user visible text.
* @param options optional options controlling behaviour
* @param layoutSaverOptions options regarding LayoutSaver behaviour
* @param engine the QML engine this dock widget will be created on. If not specified then
* Config::self().qmlEngine() will be used
*
* There's no parent argument. The DockWidget is either parented to FloatingWindow or MainWindow
* when visible, or stays without a parent when hidden.
*/
explicit DockWidgetQuick(const QString &uniqueName, Options options = {},
LayoutSaverOptions layoutSaverOptions = LayoutSaverOptions());
LayoutSaverOptions layoutSaverOptions = LayoutSaverOptions(),
QQmlEngine *engine = nullptr);
///@brief destructor
~DockWidgetQuick() override;

View File

@@ -179,7 +179,7 @@ void DockWidgetInstantiator::componentComplete()
return;
}
m_dockWidget = new DockWidgetQuick(m_uniqueName);
m_dockWidget = new DockWidgetQuick(m_uniqueName, {}, {}, qmlEngine(this));
connect(m_dockWidget, &DockWidgetQuick::titleChanged, this,
&DockWidgetInstantiator::titleChanged);