I would like to set an integer number to be stored in a QWidget
, and I think the setUserData
member function would do the trick but I can't find any documentation. Any hints?
The tree-like organization of QWidgets (and in fact of any QObjects ) is part of the memory management strategy used within the Qt-Framework. Assigning a QObject to a parent means that ownership of the child object is transferred to the parent object. If the parent is deleted, all its children are also deleted.
All Qt widgets inherit QObject. The convenience function isWidgetType() returns whether an object is actually a widget. It is much faster than qobject_cast<QWidget *>(obj) or obj->inherits("QWidget"). Some QObject functions, e.g. children(), return a QObjectList.
Use QWidget::move() to set the position, QWidget::resize() to set the size and reimplement the parent's resizeEvent() handler if you need to re-position the widgets if their parent resizes. Show activity on this post. You just need to create your widget, indicate its parent QWidget and then display it.
You might be looking for QObject::setProperty()
(which is of course inherited by QWidget
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With