qml: Add support for the MainWindow

Not really a MainWindow in the sense of toolbars and all.
For qml it's just the drop area, acepting drops
This commit is contained in:
Sergio Martins
2020-08-03 19:58:52 +01:00
parent 1cfceb4d07
commit 52626b1874
14 changed files with 145 additions and 221 deletions

View File

@@ -266,7 +266,8 @@ Qt::WindowFlags QWidgetAdapter::windowFlags() const
return m_requestedWindowFlags;
}
QQuickItem *QWidgetAdapter::createItem(QQmlEngine *engine, const QString &filename) const
/** static */
QQuickItem *QWidgetAdapter::createItem(QQmlEngine *engine, const QString &filename)
{
QQmlComponent component(engine, filename);
QObject *obj = component.create();
@@ -278,6 +279,30 @@ QQuickItem *QWidgetAdapter::createItem(QQmlEngine *engine, const QString &filena
return qobject_cast<QQuickItem*>(obj);
}
void QWidgetAdapter::makeItemFillParent(QQuickItem *item)
{
// This is equivalent to "anchors.fill: parent
if (!item) {
qWarning() << Q_FUNC_INFO << "Invalid item";
return;
}
QQuickItem *parentItem = item->parentItem();
if (!parentItem) {
qWarning() << Q_FUNC_INFO << "Invalid parentItem for" << item;
return;
}
QObject *anchors = item->property("anchors").value<QObject*>();
if (!anchors) {
qWarning() << Q_FUNC_INFO << "Invalid anchors for" << item;
return;
}
anchors->setProperty("fill", QVariant::fromValue(parentItem));
}
void QWidgetAdapter::setFlag(Qt::WindowType f, bool on)
{
if (QWindow *w = windowHandle()) {