EDIT: what Cuba Ober offers is infinitely simpler and more reliable, I still leave my answer here since I found it somewhat interesting (and the approach to C ++ custom components can be changed to filter window events, as suggested )
Forgive me, but I wrote a quick and ugly hack to make sure it is possible, it only covers the second part of your question (without updating the content). My solution blocks the redrawing of the element, but also hides it as soon as an update is requested for it (which may not be a problem for you).
After reading the QQuickItem :: updatePaintNode documentation and especially this phrase
The function is called as a result of QQuickItem :: update () if the user set the QQuickItem :: ItemHasContents flag on the element.
I created a C ++ class to set / unset this flag on an arbitrary QQuickItem:
#ifndef ITEMUPDATEBLOCKER_H #define ITEMUPDATEBLOCKER_H #include <QObject> #include <QQuickItem> class ItemUpdateBlocker : public QObject { Q_OBJECT Q_PROPERTY(QQuickItem* target READ target WRITE setTarget NOTIFY targetChanged) QQuickItem* m_target; public: explicit ItemUpdateBlocker(QObject *parent = 0) : QObject(parent), m_target(nullptr) { } QQuickItem* target() const { return m_target; } signals: void targetChanged(); private: static void blockUpdate(QQuickItem* target) { if (target) target->setFlag(QQuickItem::ItemHasContents, false); } static void unblockUpdate(QQuickItem* target) { if (target) { target->setFlag(QQuickItem::ItemHasContents, true); target->update(); } } public slots: void setTarget(QQuickItem* target) { if (m_target == target) return; unblockUpdate(m_target); blockUpdate(target); m_target = target; emit targetChanged(); } }; #endif // ITEMUPDATEBLOCKER_H
The next step is to register this class so that it can be used in QML:
qmlRegisterType<ItemUpdateBlocker>("com.mycompany.qmlcomponents", 1, 0, "ItemUpdateBlocker");
And you can use it in QML as follows:
import QtQuick 2.4 import QtQuick.Controls 1.3 import QtQuick.Window 2.2 import com.mycompany.qmlcomponents 1.0 ApplicationWindow { width: 640 height: 480 visible: true Rectangle { color: "red" id: root anchors.fill: parent Text { text: blocker.target ? "Blocked" : "Not Blocked" } Rectangle { color: "white" anchors.centerIn: parent width: parent.width/2 height: parent.height/2 ItemUpdateBlocker { id: blocker; } MouseArea { anchors.fill: parent onClicked: blocker.target = blocker.target ? null : parent } } } }
Of course, you can add the active property to the blocker to make it easier to use (more beautiful than using null target to disable it), but I will leave this as an exercise.
Perhaps you can use this when starting a timer when changing the width or height of your Window , I have not yet found a direct way to find if the window has changed.