Is there any other method to resize the controls like "OnWidthChanged()" dose in QML?
-
onWidthChanged doesn't resize anything. It's a signal that fires after the fact.
I suspect you would like to be aware of layouts and anchors... but perhaps you maybe wish to ask that question again?
Low effort questions are almost, if not, insulting to people who are putting in effort in for free to genuinely try and be helpful, the least you can do it try as well.
-
@6thC said in Is there any other method to resize the controls like "OnWidthChanged()" dose in QML?:
onWidthChanged doesn't resize anything. It's a signal that fires after the fact.
I suspect you would like to be aware of layouts and anchors... but perhaps you maybe wish to ask that question again?no layouts and anchors.I would like to know those signals QML.Controls notifying the change in size.
-
@6thC said in Is there any other method to resize the controls like "OnWidthChanged()" dose in QML?:
onWidthChanged doesn't resize anything. It's a signal that fires after the fact.
I suspect you would like to be aware of layouts and anchors... but perhaps you maybe wish to ask that question again?no layouts and anchors.I would like to know those signals QML.Controls notifying the change in size.
@mirro said in Is there any other method to resize the controls like "OnWidthChanged()" dose in QML?:
no layouts and anchors.I would like to know those signals QML.Controls notifying the change in size.
Can you please explain what is the problem you try to solve?
I don't understand what you are asking for, so I can not help you. -
@mirro said in Is there any other method to resize the controls like "OnWidthChanged()" dose in QML?:
no layouts and anchors.I would like to know those signals QML.Controls notifying the change in size.
Can you please explain what is the problem you try to solve?
I don't understand what you are asking for, so I can not help you.How does quickwidget correctly get geometric information from QML in C++.
The Rectangle geometry fom QML that I get in the resizeEvent() event is null value.
import QtQuick 2.7 import QtQuick.Controls 2.0 Item { id:view visible: true Rectangle{ id:rct objectName:"Rct" anchors.fill: parent color:'red' } } class cusQQuickWidget:public QuickWidget{ Q_OBJECT public: cusQQuickWidget(QWidget* parent = nullptr):QuickWidget(parent){} virtual ~cusQQuickWidget(){} protected: void resizeEvent(QResizeEvent* p) { QQuickWidget::resizeEvent(p); // QQuickItem* pItem = rootObject(); QObject rect = pItem->findChild<QObject>("Rct"); if (rect) { //All is null value QVariant x = rect->property("x"); QVariant x = rect->property("y"); QVariant wid = rect->property("width"); QVariant hei = rect->property("height"); } } } ``
-
How does quickwidget correctly get geometric information from QML in C++.
The Rectangle geometry fom QML that I get in the resizeEvent() event is null value.
import QtQuick 2.7 import QtQuick.Controls 2.0 Item { id:view visible: true Rectangle{ id:rct objectName:"Rct" anchors.fill: parent color:'red' } } class cusQQuickWidget:public QuickWidget{ Q_OBJECT public: cusQQuickWidget(QWidget* parent = nullptr):QuickWidget(parent){} virtual ~cusQQuickWidget(){} protected: void resizeEvent(QResizeEvent* p) { QQuickWidget::resizeEvent(p); // QQuickItem* pItem = rootObject(); QObject rect = pItem->findChild<QObject>("Rct"); if (rect) { //All is null value QVariant x = rect->property("x"); QVariant x = rect->property("y"); QVariant wid = rect->property("width"); QVariant hei = rect->property("height"); } } } ``
@mirro said in Is there any other method to resize the controls like "OnWidthChanged()" dose in QML?:
How does quickwidget correctly get geometric information from QML in C++.
I suppose you are loading the QML into your custom
QuickWidget
, but you did never set the width and height from your top element, so they are 0!
Simply change your QML to set width and height like this:import QtQuick 2.7 import QtQuick.Controls 2.0 Item { id:view visible: true width: parent.width height: parent.height Rectangle{ id:rct objectName:"Rct" anchors.fill: parent color:'red' } }
-
alternatively, use setResizeMode of your QQuickWidget and set it to
SizeRootObjectToView
, may solve all your issues.