#[repr(C)]pub struct QGraphicsProxyWidget { /* private fields */ }
Expand description
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene.
C++ class: QGraphicsProxyWidget
.
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene.
QGraphicsProxyWidget embeds QWidget-based widgets, for example, a QPushButton, QFontComboBox, or even QFileDialog, into QGraphicsScene. It forwards events between the two objects and translates between QWidget's integer-based geometry and QGraphicsWidget's qreal-based geometry. QGraphicsProxyWidget supports all core features of QWidget, including tab focus, keyboard input, Drag & Drop, and popups. You can also embed complex widgets, e.g., widgets with subwidgets.
Example:
int main(int argc, char argv) { QApplication app(argc, argv);
QTabWidget *tabWidget = new QTabWidget;
QGraphicsScene scene; QGraphicsProxyWidget *proxy = scene.addWidget(tabWidget);
QGraphicsView view(&scene); view.show();
return app.exec(); }
QGraphicsProxyWidget takes care of automatically embedding popup children of embedded widgets through creating a child proxy for each popup. This means that when an embedded QComboBox shows its popup list, a new QGraphicsProxyWidget is created automatically, embedding the popup, and positioning it correctly. This only works if the popup is child of the embedded widget (for example QToolButton::setMenu() requires the QMenu instance to be child of the QToolButton).
Implementations§
Source§impl QGraphicsProxyWidget
impl QGraphicsProxyWidget
Sourcepub fn slot_new_proxy_widget(&self) -> Receiver<(*const QWidget,)>
pub fn slot_new_proxy_widget(&self) -> Receiver<(*const QWidget,)>
Creates a proxy widget for the given child of the widget contained in this proxy.
Returns a built-in Qt slot QGraphicsProxyWidget::newProxyWidget
that can be passed to qt_core::Signal::connect
.
Creates a proxy widget for the given child of the widget contained in this proxy.
You should not call this function directly; use QGraphicsProxyWidget::createProxyForChildWidget() instead.
This function is a fake virtual slot that you can reimplement in your subclass in order to control how new proxy widgets are created. The default implementation returns a proxy created with the QGraphicsProxyWidget() constructor with this proxy widget as the parent.
This function was introduced in Qt 4.5.
See also createProxyForChildWidget().
Sourcepub unsafe fn create_proxy_for_child_widget(
&self,
child: impl CastInto<Ptr<QWidget>>,
) -> QPtr<QGraphicsProxyWidget>
pub unsafe fn create_proxy_for_child_widget( &self, child: impl CastInto<Ptr<QWidget>>, ) -> QPtr<QGraphicsProxyWidget>
Creates a proxy widget for the given child of the widget contained in this proxy.
Calls C++ function: QGraphicsProxyWidget* QGraphicsProxyWidget::createProxyForChildWidget(QWidget* child)
.
Creates a proxy widget for the given child of the widget contained in this proxy.
This function makes it possible to acquire proxies for non top-level widgets. For instance, you can embed a dialog, and then transform only one of its widgets.
If the widget is already embedded, return the existing proxy widget.
This function was introduced in Qt 4.5.
See also newProxyWidget() and QGraphicsScene::addWidget().
Sourcepub unsafe fn meta_object(&self) -> Ptr<QMetaObject>
pub unsafe fn meta_object(&self) -> Ptr<QMetaObject>
Calls C++ function: virtual const QMetaObject* QGraphicsProxyWidget::metaObject() const
.
Sourcepub unsafe fn new_2a(
parent: impl CastInto<Ptr<QGraphicsItem>>,
w_flags: QFlags<WindowType>,
) -> QBox<QGraphicsProxyWidget>
pub unsafe fn new_2a( parent: impl CastInto<Ptr<QGraphicsItem>>, w_flags: QFlags<WindowType>, ) -> QBox<QGraphicsProxyWidget>
Constructs a new QGraphicsProxy widget. parent and wFlags are passed to QGraphicsItem's constructor.
Calls C++ function: [constructor] void QGraphicsProxyWidget::QGraphicsProxyWidget(QGraphicsItem* parent = …, QFlags<Qt::WindowType> wFlags = …)
.
Constructs a new QGraphicsProxy widget. parent and wFlags are passed to QGraphicsItem’s constructor.
Sourcepub unsafe fn new_0a() -> QBox<QGraphicsProxyWidget>
pub unsafe fn new_0a() -> QBox<QGraphicsProxyWidget>
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene.
Calls C++ function: [constructor] void QGraphicsProxyWidget::QGraphicsProxyWidget()
.
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene.
QGraphicsProxyWidget embeds QWidget-based widgets, for example, a QPushButton, QFontComboBox, or even QFileDialog, into QGraphicsScene. It forwards events between the two objects and translates between QWidget's integer-based geometry and QGraphicsWidget's qreal-based geometry. QGraphicsProxyWidget supports all core features of QWidget, including tab focus, keyboard input, Drag & Drop, and popups. You can also embed complex widgets, e.g., widgets with subwidgets.
Example:
int main(int argc, char argv) { QApplication app(argc, argv);
QTabWidget *tabWidget = new QTabWidget;
QGraphicsScene scene; QGraphicsProxyWidget *proxy = scene.addWidget(tabWidget);
QGraphicsView view(&scene); view.show();
return app.exec(); }
QGraphicsProxyWidget takes care of automatically embedding popup children of embedded widgets through creating a child proxy for each popup. This means that when an embedded QComboBox shows its popup list, a new QGraphicsProxyWidget is created automatically, embedding the popup, and positioning it correctly. This only works if the popup is child of the embedded widget (for example QToolButton::setMenu() requires the QMenu instance to be child of the QToolButton).
Sourcepub unsafe fn new_1a(
parent: impl CastInto<Ptr<QGraphicsItem>>,
) -> QBox<QGraphicsProxyWidget>
pub unsafe fn new_1a( parent: impl CastInto<Ptr<QGraphicsItem>>, ) -> QBox<QGraphicsProxyWidget>
Constructs a new QGraphicsProxy widget. parent and wFlags are passed to QGraphicsItem's constructor.
Calls C++ function: [constructor] void QGraphicsProxyWidget::QGraphicsProxyWidget(QGraphicsItem* parent = …)
.
Constructs a new QGraphicsProxy widget. parent and wFlags are passed to QGraphicsItem’s constructor.
Sourcepub unsafe fn paint(
&self,
painter: impl CastInto<Ptr<QPainter>>,
option: impl CastInto<Ptr<QStyleOptionGraphicsItem>>,
widget: impl CastInto<Ptr<QWidget>>,
)
pub unsafe fn paint( &self, painter: impl CastInto<Ptr<QPainter>>, option: impl CastInto<Ptr<QStyleOptionGraphicsItem>>, widget: impl CastInto<Ptr<QWidget>>, )
Reimplemented from QGraphicsItem::paint().
Calls C++ function: virtual void QGraphicsProxyWidget::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
.
Reimplemented from QGraphicsItem::paint().
Sourcepub unsafe fn qt_metacall(
&self,
arg1: Call,
arg2: c_int,
arg3: *mut *mut c_void,
) -> c_int
pub unsafe fn qt_metacall( &self, arg1: Call, arg2: c_int, arg3: *mut *mut c_void, ) -> c_int
Calls C++ function: virtual int QGraphicsProxyWidget::qt_metacall(QMetaObject::Call arg1, int arg2, void** arg3)
.
Sourcepub unsafe fn qt_metacast(&self, arg1: *const c_char) -> *mut c_void
pub unsafe fn qt_metacast(&self, arg1: *const c_char) -> *mut c_void
Calls C++ function: virtual void* QGraphicsProxyWidget::qt_metacast(const char* arg1)
.
Sourcepub unsafe fn set_geometry(&self, rect: impl CastInto<Ref<QRectF>>)
pub unsafe fn set_geometry(&self, rect: impl CastInto<Ref<QRectF>>)
Reimplemented from QGraphicsLayoutItem::setGeometry().
Calls C++ function: virtual void QGraphicsProxyWidget::setGeometry(const QRectF& rect)
.
Reimplemented from QGraphicsLayoutItem::setGeometry().
Sourcepub unsafe fn set_widget(&self, widget: impl CastInto<Ptr<QWidget>>)
pub unsafe fn set_widget(&self, widget: impl CastInto<Ptr<QWidget>>)
Embeds widget into this proxy widget. The embedded widget must reside exclusively either inside or outside of Graphics View. You cannot embed a widget as long as it is is visible elsewhere in the UI, at the same time.
Calls C++ function: void QGraphicsProxyWidget::setWidget(QWidget* widget)
.
Embeds widget into this proxy widget. The embedded widget must reside exclusively either inside or outside of Graphics View. You cannot embed a widget as long as it is is visible elsewhere in the UI, at the same time.
widget must be a top-level widget whose parent is 0.
When the widget is embedded, its state (e.g., visible, enabled, geometry, size hints) is copied into the proxy widget. If the embedded widget is explicitly hidden or disabled, the proxy widget will become explicitly hidden or disabled after embedding is complete. The class documentation has a full overview over the shared state.
QGraphicsProxyWidget's window flags determine whether the widget, after embedding, will be given window decorations or not.
After this function returns, QGraphicsProxyWidget will keep its state synchronized with that of widget whenever possible.
If a widget is already embedded by this proxy when this function is called, that widget will first be automatically unembedded. Passing 0 for the widget argument will only unembed the widget, and the ownership of the currently embedded widget will be passed on to the caller. Every child widget that are embedded will also be embedded and their proxy widget destroyed.
Note that widgets with the Qt::WA_PaintOnScreen widget attribute set and widgets that wrap an external application or controller cannot be embedded. Examples are QGLWidget and QAxWidget.
See also widget().
Sourcepub unsafe fn static_meta_object() -> Ref<QMetaObject>
pub unsafe fn static_meta_object() -> Ref<QMetaObject>
Returns a reference to the staticMetaObject
field.
Sourcepub unsafe fn sub_widget_rect(
&self,
widget: impl CastInto<Ptr<QWidget>>,
) -> CppBox<QRectF>
pub unsafe fn sub_widget_rect( &self, widget: impl CastInto<Ptr<QWidget>>, ) -> CppBox<QRectF>
Sourcepub unsafe fn tr(
s: *const c_char,
c: *const c_char,
n: c_int,
) -> CppBox<QString>
pub unsafe fn tr( s: *const c_char, c: *const c_char, n: c_int, ) -> CppBox<QString>
Calls C++ function: static QString QGraphicsProxyWidget::tr(const char* s, const char* c, int n)
.
Sourcepub unsafe fn tr_utf8(
s: *const c_char,
c: *const c_char,
n: c_int,
) -> CppBox<QString>
pub unsafe fn tr_utf8( s: *const c_char, c: *const c_char, n: c_int, ) -> CppBox<QString>
Calls C++ function: static QString QGraphicsProxyWidget::trUtf8(const char* s, const char* c, int n)
.
Sourcepub unsafe fn type_(&self) -> c_int
pub unsafe fn type_(&self) -> c_int
Reimplemented from QGraphicsItem::type().
Calls C++ function: virtual int QGraphicsProxyWidget::type() const
.
Reimplemented from QGraphicsItem::type().
Methods from Deref<Target = QGraphicsWidget>§
Sourcepub fn geometry_changed(&self) -> Signal<()>
pub fn geometry_changed(&self) -> Signal<()>
This signal gets emitted whenever the geometry is changed in setGeometry().
Returns a built-in Qt signal QGraphicsWidget::geometryChanged
that can be passed to qt_core::Signal::connect
.
This signal gets emitted whenever the geometry is changed in setGeometry().
Note: Notifier signal for property geometry. Notifier signal for property size.
Sourcepub fn layout_changed(&self) -> Signal<()>
pub fn layout_changed(&self) -> Signal<()>
This property holds the layout of the widget
Returns a built-in Qt signal QGraphicsWidget::layoutChanged
that can be passed to qt_core::Signal::connect
.
This property holds the layout of the widget
Any existing layout manager is deleted before the new layout is assigned. If layout is nullptr
, the widget is left without a layout. Existing subwidgets' geometries will remain unaffected.
QGraphicsWidget takes ownership of layout.
All widgets that are currently managed by layout or all of its sublayouts, are automatically reparented to this item. The layout is then invalidated, and the child widget geometries are adjusted according to this item's geometry() and contentsMargins(). Children who are not explicitly managed by layout remain unaffected by the layout after it has been assigned to this widget.
If no layout is currently managing this widget, layout() will return nullptr
.
Access functions:
Notifier signal:
void | layoutChanged() |
Sourcepub fn slot_close(&self) -> Receiver<()>
pub fn slot_close(&self) -> Receiver<()>
Call this function to close the widget.
Returns a built-in Qt slot QGraphicsWidget::close
that can be passed to qt_core::Signal::connect
.
Call this function to close the widget.
Returns true
if the widget was closed; otherwise returns false
. This slot will first send a QCloseEvent to the widget, which may or may not accept the event. If the event was ignored, nothing happens. If the event was accepted, it will hide() the widget.
If the widget has the Qt::WA_DeleteOnClose attribute set it will be deleted.
Sourcepub unsafe fn actions(&self) -> CppBox<QListOfQAction>
pub unsafe fn actions(&self) -> CppBox<QListOfQAction>
Returns the (possibly empty) list of this widget's actions.
Calls C++ function: QList<QAction*> QGraphicsWidget::actions() const
.
Returns the (possibly empty) list of this widget’s actions.
This function was introduced in Qt 4.5.
See also insertAction(), removeAction(), QWidget::actions(), QAction::associatedWidgets(), and QAction::associatedGraphicsWidgets().
Sourcepub unsafe fn add_action(&self, action: impl CastInto<Ptr<QAction>>)
pub unsafe fn add_action(&self, action: impl CastInto<Ptr<QAction>>)
Appends the action action to this widget's list of actions.
Calls C++ function: void QGraphicsWidget::addAction(QAction* action)
.
Appends the action action to this widget’s list of actions.
All QGraphicsWidgets have a list of QActions, however they can be represented graphically in many different ways. The default use of the QAction list (as returned by actions()) is to create a context QMenu.
A QGraphicsWidget should only have one of each action and adding an action it already has will not cause the same action to be in the widget twice.
This function was introduced in Qt 4.5.
See also removeAction(), insertAction(), actions(), and QWidget::addAction().
Sourcepub unsafe fn add_actions(&self, actions: impl CastInto<Ref<QListOfQAction>>)
pub unsafe fn add_actions(&self, actions: impl CastInto<Ref<QListOfQAction>>)
Appends the actions actions to this widget's list of actions.
Calls C++ function: void QGraphicsWidget::addActions(QList<QAction*> actions)
.
Appends the actions actions to this widget’s list of actions.
This function was introduced in Qt 4.5.
See also removeAction(), QMenu, addAction(), and QWidget::addActions().
Sourcepub unsafe fn adjust_size(&self)
pub unsafe fn adjust_size(&self)
Adjusts the size of the widget to its effective preferred size hint.
Calls C++ function: void QGraphicsWidget::adjustSize()
.
Adjusts the size of the widget to its effective preferred size hint.
This function is called implicitly when the item is shown for the first time.
See also effectiveSizeHint() and Qt::MinimumSize.
Sourcepub unsafe fn auto_fill_background(&self) -> bool
pub unsafe fn auto_fill_background(&self) -> bool
This property holds whether the widget background is filled automatically
Calls C++ function: bool QGraphicsWidget::autoFillBackground() const
.
This property holds whether the widget background is filled automatically
If enabled, this property will cause Qt to fill the background of the widget before invoking the paint() method. The color used is defined by the QPalette::Window color role from the widget's palette.
In addition, Windows are always filled with QPalette::Window, unless the WA_OpaquePaintEvent or WA_NoSystemBackground attributes are set.
By default, this property is false
.
This property was introduced in Qt 4.7.
Access functions:
bool | autoFillBackground() const |
void | setAutoFillBackground(bool enabled) |
See also Qt::WA_OpaquePaintEvent and Qt::WA_NoSystemBackground.
Sourcepub unsafe fn bounding_rect(&self) -> CppBox<QRectF>
pub unsafe fn bounding_rect(&self) -> CppBox<QRectF>
Reimplemented from QGraphicsItem::boundingRect().
Calls C++ function: virtual QRectF QGraphicsWidget::boundingRect() const
.
Reimplemented from QGraphicsItem::boundingRect().
Sourcepub unsafe fn close(&self) -> bool
pub unsafe fn close(&self) -> bool
Call this function to close the widget.
Calls C++ function: [slot] bool QGraphicsWidget::close()
.
Call this function to close the widget.
Returns true
if the widget was closed; otherwise returns false
. This slot will first send a QCloseEvent to the widget, which may or may not accept the event. If the event was ignored, nothing happens. If the event was accepted, it will hide() the widget.
If the widget has the Qt::WA_DeleteOnClose attribute set it will be deleted.
Sourcepub unsafe fn focus_policy(&self) -> FocusPolicy
pub unsafe fn focus_policy(&self) -> FocusPolicy
This property holds the way the widget accepts keyboard focus
Calls C++ function: Qt::FocusPolicy QGraphicsWidget::focusPolicy() const
.
This property holds the way the widget accepts keyboard focus
The focus policy is Qt::TabFocus if the widget accepts keyboard focus by tabbing, Qt::ClickFocus if the widget accepts focus by clicking, Qt::StrongFocus if it accepts both, and Qt::NoFocus (the default) if it does not accept focus at all.
You must enable keyboard focus for a widget if it processes keyboard events. This is normally done from the widget's constructor. For instance, the QLineEdit constructor calls setFocusPolicy(Qt::StrongFocus).
If you enable a focus policy (i.e., not Qt::NoFocus), QGraphicsWidget will automatically enable the ItemIsFocusable flag. Setting Qt::NoFocus on a widget will clear the ItemIsFocusable flag. If the widget currently has keyboard focus, the widget will automatically lose focus.
Access functions:
Qt::FocusPolicy | focusPolicy() const |
void | setFocusPolicy(Qt::FocusPolicy policy) |
See also focusInEvent(), focusOutEvent(), keyPressEvent(), keyReleaseEvent(), and enabled.
Sourcepub unsafe fn focus_widget(&self) -> QPtr<QGraphicsWidget>
pub unsafe fn focus_widget(&self) -> QPtr<QGraphicsWidget>
If this widget, a child or descendant of this widget currently has input focus, this function will return a pointer to that widget. If no descendant widget has input focus, 0 is returned.
Calls C++ function: QGraphicsWidget* QGraphicsWidget::focusWidget() const
.
If this widget, a child or descendant of this widget currently has input focus, this function will return a pointer to that widget. If no descendant widget has input focus, 0 is returned.
See also QGraphicsItem::focusItem() and QWidget::focusWidget().
Sourcepub unsafe fn font(&self) -> CppBox<QFont>
pub unsafe fn font(&self) -> CppBox<QFont>
This property holds the widgets' font
Calls C++ function: QFont QGraphicsWidget::font() const
.
This property holds the widgets’ font
This property provides the widget's font.
QFont consists of font properties that have been explicitly defined and properties implicitly inherited from the widget's parent. Hence, font() can return a different font compared to the one set with setFont(). This scheme allows you to define single entries in a font without affecting the font's inherited entries.
When a widget's font changes, it resolves its entries against its parent widget. If the widget does not have a parent widget, it resolves its entries against the scene. The widget then sends itself a FontChange event and notifies all its descendants so that they can resolve their fonts as well.
By default, this property contains the application's default font.
Access functions:
QFont | font() const |
void | setFont(const QFont &font) |
See also QApplication::font(), QGraphicsScene::font, and QFont::resolve().
Sourcepub unsafe fn get_contents_margins(
&self,
left: *mut c_double,
top: *mut c_double,
right: *mut c_double,
bottom: *mut c_double,
)
pub unsafe fn get_contents_margins( &self, left: *mut c_double, top: *mut c_double, right: *mut c_double, bottom: *mut c_double, )
Reimplemented from QGraphicsLayoutItem::getContentsMargins().
Calls C++ function: virtual void QGraphicsWidget::getContentsMargins(double* left, double* top, double* right, double* bottom) const
.
Reimplemented from QGraphicsLayoutItem::getContentsMargins().
Gets the widget's contents margins. The margins are stored in left, top, right and bottom, as pointers to qreals. Each argument can be omitted by passing 0.
See also setContentsMargins().
Sourcepub unsafe fn get_window_frame_margins(
&self,
left: *mut c_double,
top: *mut c_double,
right: *mut c_double,
bottom: *mut c_double,
)
pub unsafe fn get_window_frame_margins( &self, left: *mut c_double, top: *mut c_double, right: *mut c_double, bottom: *mut c_double, )
Gets the widget's window frame margins. The margins are stored in left, top, right and bottom as pointers to qreals. Each argument can be omitted by passing 0.
Calls C++ function: void QGraphicsWidget::getWindowFrameMargins(double* left, double* top, double* right, double* bottom) const
.
Gets the widget’s window frame margins. The margins are stored in left, top, right and bottom as pointers to qreals. Each argument can be omitted by passing 0.
See also setWindowFrameMargins() and windowFrameRect().
Sourcepub unsafe fn grab_shortcut_2a(
&self,
sequence: impl CastInto<Ref<QKeySequence>>,
context: ShortcutContext,
) -> c_int
pub unsafe fn grab_shortcut_2a( &self, sequence: impl CastInto<Ref<QKeySequence>>, context: ShortcutContext, ) -> c_int
Adds a shortcut to Qt's shortcut system that watches for the given key sequence in the given context. If the context is Qt::ApplicationShortcut, the shortcut applies to the application as a whole. Otherwise, it is either local to this widget, Qt::WidgetShortcut, or to the window itself, Qt::WindowShortcut. For widgets that are not part of a window (i.e., top-level widgets and their children), Qt::WindowShortcut shortcuts apply to the scene.
Calls C++ function: int QGraphicsWidget::grabShortcut(const QKeySequence& sequence, Qt::ShortcutContext context = …)
.
Adds a shortcut to Qt’s shortcut system that watches for the given key sequence in the given context. If the context is Qt::ApplicationShortcut, the shortcut applies to the application as a whole. Otherwise, it is either local to this widget, Qt::WidgetShortcut, or to the window itself, Qt::WindowShortcut. For widgets that are not part of a window (i.e., top-level widgets and their children), Qt::WindowShortcut shortcuts apply to the scene.
If the same key sequence has been grabbed by several widgets, when the key sequence occurs a QEvent::Shortcut event is sent to all the widgets to which it applies in a non-deterministic order, but with the ``ambiguous'' flag set to true.
Warning: You should not normally need to use this function; instead create QActions with the shortcut key sequences you require (if you also want equivalent menu options and toolbar buttons), or create QShortcuts if you just need key sequences. Both QAction and QShortcut handle all the event filtering for you, and provide signals which are triggered when the user triggers the key sequence, so are much easier to use than this low-level function.
This function was introduced in Qt 4.5.
See also releaseShortcut(), setShortcutEnabled(), and QWidget::grabShortcut().
Sourcepub unsafe fn grab_shortcut_1a(
&self,
sequence: impl CastInto<Ref<QKeySequence>>,
) -> c_int
pub unsafe fn grab_shortcut_1a( &self, sequence: impl CastInto<Ref<QKeySequence>>, ) -> c_int
Adds a shortcut to Qt's shortcut system that watches for the given key sequence in the given context. If the context is Qt::ApplicationShortcut, the shortcut applies to the application as a whole. Otherwise, it is either local to this widget, Qt::WidgetShortcut, or to the window itself, Qt::WindowShortcut. For widgets that are not part of a window (i.e., top-level widgets and their children), Qt::WindowShortcut shortcuts apply to the scene.
Calls C++ function: int QGraphicsWidget::grabShortcut(const QKeySequence& sequence)
.
Adds a shortcut to Qt’s shortcut system that watches for the given key sequence in the given context. If the context is Qt::ApplicationShortcut, the shortcut applies to the application as a whole. Otherwise, it is either local to this widget, Qt::WidgetShortcut, or to the window itself, Qt::WindowShortcut. For widgets that are not part of a window (i.e., top-level widgets and their children), Qt::WindowShortcut shortcuts apply to the scene.
If the same key sequence has been grabbed by several widgets, when the key sequence occurs a QEvent::Shortcut event is sent to all the widgets to which it applies in a non-deterministic order, but with the ``ambiguous'' flag set to true.
Warning: You should not normally need to use this function; instead create QActions with the shortcut key sequences you require (if you also want equivalent menu options and toolbar buttons), or create QShortcuts if you just need key sequences. Both QAction and QShortcut handle all the event filtering for you, and provide signals which are triggered when the user triggers the key sequence, so are much easier to use than this low-level function.
This function was introduced in Qt 4.5.
See also releaseShortcut(), setShortcutEnabled(), and QWidget::grabShortcut().
Sourcepub unsafe fn insert_action(
&self,
before: impl CastInto<Ptr<QAction>>,
action: impl CastInto<Ptr<QAction>>,
)
pub unsafe fn insert_action( &self, before: impl CastInto<Ptr<QAction>>, action: impl CastInto<Ptr<QAction>>, )
Inserts the action action to this widget's list of actions, before the action before. It appends the action if before is 0 or before is not a valid action for this widget.
Calls C++ function: void QGraphicsWidget::insertAction(QAction* before, QAction* action)
.
Inserts the action action to this widget’s list of actions, before the action before. It appends the action if before is 0 or before is not a valid action for this widget.
A QGraphicsWidget should only have one of each action.
This function was introduced in Qt 4.5.
See also removeAction(), addAction(), QMenu, actions(), and QWidget::insertActions().
Sourcepub unsafe fn insert_actions(
&self,
before: impl CastInto<Ptr<QAction>>,
actions: impl CastInto<Ref<QListOfQAction>>,
)
pub unsafe fn insert_actions( &self, before: impl CastInto<Ptr<QAction>>, actions: impl CastInto<Ref<QListOfQAction>>, )
Inserts the actions actions to this widget's list of actions, before the action before. It appends the action if before is 0 or before is not a valid action for this widget.
Calls C++ function: void QGraphicsWidget::insertActions(QAction* before, QList<QAction*> actions)
.
Inserts the actions actions to this widget’s list of actions, before the action before. It appends the action if before is 0 or before is not a valid action for this widget.
A QGraphicsWidget can have at most one of each action.
This function was introduced in Qt 4.5.
See also removeAction(), QMenu, insertAction(), and QWidget::insertActions().
Sourcepub unsafe fn is_active_window(&self) -> bool
pub unsafe fn is_active_window(&self) -> bool
Returns true
if this widget's window is in the active window, or if the widget does not have a window but is in an active scene (i.e., a scene that currently has focus).
Calls C++ function: bool QGraphicsWidget::isActiveWindow() const
.
Returns true
if this widget’s window is in the active window, or if the widget does not have a window but is in an active scene (i.e., a scene that currently has focus).
The active window is the window that either contains a child widget that currently has input focus, or that itself has input focus.
See also QGraphicsScene::activeWindow(), QGraphicsScene::setActiveWindow(), and isActive().
Sourcepub unsafe fn layout(&self) -> Ptr<QGraphicsLayout>
pub unsafe fn layout(&self) -> Ptr<QGraphicsLayout>
This property holds the layout of the widget
Calls C++ function: QGraphicsLayout* QGraphicsWidget::layout() const
.
This property holds the layout of the widget
Any existing layout manager is deleted before the new layout is assigned. If layout is 0, the widget is left without a layout. Existing subwidgets' geometries will remain unaffected.
QGraphicsWidget takes ownership of layout.
All widgets that are currently managed by layout or all of its sublayouts, are automatically reparented to this item. The layout is then invalidated, and the child widget geometries are adjusted according to this item's geometry() and contentsMargins(). Children who are not explicitly managed by layout remain unaffected by the layout after it has been assigned to this widget.
If no layout is currently managing this widget, layout() will return 0.
Access functions:
Sourcepub unsafe fn layout_direction(&self) -> LayoutDirection
pub unsafe fn layout_direction(&self) -> LayoutDirection
This property holds the layout direction for this widget.
Calls C++ function: Qt::LayoutDirection QGraphicsWidget::layoutDirection() const
.
This property holds the layout direction for this widget.
This property modifies this widget's and all of its descendants' Qt::WA_RightToLeft attribute. It also sets this widget's Qt::WA_SetLayoutDirection attribute.
The widget's layout direction determines the order in which the layout manager horizontally arranges subwidgets of this widget. The default value depends on the language and locale of the application, and is typically in the same direction as words are read and written. With Qt::LeftToRight, the layout starts placing subwidgets from the left side of this widget towards the right. Qt::RightToLeft does the opposite - the layout will place widgets starting from the right edge moving towards the left.
Subwidgets inherit their layout direction from the parent. Top-level widget items inherit their layout direction from QGraphicsScene::layoutDirection. If you change a widget's layout direction by calling setLayoutDirection(), the widget will send itself a LayoutDirectionChange event, and then propagate the new layout direction to all its descendants.
Access functions:
Qt::LayoutDirection | layoutDirection() const |
void | setLayoutDirection(Qt::LayoutDirection direction) |
void | unsetLayoutDirection() |
See also QWidget::layoutDirection and QApplication::layoutDirection.
Sourcepub unsafe fn meta_object(&self) -> Ptr<QMetaObject>
pub unsafe fn meta_object(&self) -> Ptr<QMetaObject>
Calls C++ function: virtual const QMetaObject* QGraphicsWidget::metaObject() const
.
Sourcepub unsafe fn paint_3a(
&self,
painter: impl CastInto<Ptr<QPainter>>,
option: impl CastInto<Ptr<QStyleOptionGraphicsItem>>,
widget: impl CastInto<Ptr<QWidget>>,
)
pub unsafe fn paint_3a( &self, painter: impl CastInto<Ptr<QPainter>>, option: impl CastInto<Ptr<QStyleOptionGraphicsItem>>, widget: impl CastInto<Ptr<QWidget>>, )
Reimplemented from QGraphicsItem::paint().
Calls C++ function: virtual void QGraphicsWidget::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = …)
.
Reimplemented from QGraphicsItem::paint().
Sourcepub unsafe fn paint_2a(
&self,
painter: impl CastInto<Ptr<QPainter>>,
option: impl CastInto<Ptr<QStyleOptionGraphicsItem>>,
)
pub unsafe fn paint_2a( &self, painter: impl CastInto<Ptr<QPainter>>, option: impl CastInto<Ptr<QStyleOptionGraphicsItem>>, )
Reimplemented from QGraphicsItem::paint().
Calls C++ function: virtual void QGraphicsWidget::paint(QPainter* painter, const QStyleOptionGraphicsItem* option)
.
Reimplemented from QGraphicsItem::paint().
Sourcepub unsafe fn paint_window_frame_3a(
&self,
painter: impl CastInto<Ptr<QPainter>>,
option: impl CastInto<Ptr<QStyleOptionGraphicsItem>>,
widget: impl CastInto<Ptr<QWidget>>,
)
pub unsafe fn paint_window_frame_3a( &self, painter: impl CastInto<Ptr<QPainter>>, option: impl CastInto<Ptr<QStyleOptionGraphicsItem>>, widget: impl CastInto<Ptr<QWidget>>, )
This virtual function is called by QGraphicsScene to draw the window frame for windows using painter, option, and widget, in local coordinates. The base implementation uses the current style to render the frame and title bar.
Calls C++ function: virtual void QGraphicsWidget::paintWindowFrame(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = …)
.
This virtual function is called by QGraphicsScene to draw the window frame for windows using painter, option, and widget, in local coordinates. The base implementation uses the current style to render the frame and title bar.
You can reimplement this function in a subclass of QGraphicsWidget to provide custom rendering of the widget's window frame.
See also QGraphicsItem::paint().
Sourcepub unsafe fn paint_window_frame_2a(
&self,
painter: impl CastInto<Ptr<QPainter>>,
option: impl CastInto<Ptr<QStyleOptionGraphicsItem>>,
)
pub unsafe fn paint_window_frame_2a( &self, painter: impl CastInto<Ptr<QPainter>>, option: impl CastInto<Ptr<QStyleOptionGraphicsItem>>, )
This virtual function is called by QGraphicsScene to draw the window frame for windows using painter, option, and widget, in local coordinates. The base implementation uses the current style to render the frame and title bar.
Calls C++ function: virtual void QGraphicsWidget::paintWindowFrame(QPainter* painter, const QStyleOptionGraphicsItem* option)
.
This virtual function is called by QGraphicsScene to draw the window frame for windows using painter, option, and widget, in local coordinates. The base implementation uses the current style to render the frame and title bar.
You can reimplement this function in a subclass of QGraphicsWidget to provide custom rendering of the widget's window frame.
See also QGraphicsItem::paint().
Sourcepub unsafe fn palette(&self) -> CppBox<QPalette>
pub unsafe fn palette(&self) -> CppBox<QPalette>
This property holds the widget's palette
Calls C++ function: QPalette QGraphicsWidget::palette() const
.
This property holds the widget’s palette
This property provides the widget's palette. The palette provides colors and brushes for color groups (e.g., QPalette::Button) and states (e.g., QPalette::Inactive), loosely defining the general look of the widget and its children.
QPalette consists of color groups that have been explicitly defined, and groups that are implicitly inherited from the widget's parent. Because of this, palette() can return a different palette than what has been set with setPalette(). This scheme allows you to define single entries in a palette without affecting the palette's inherited entries.
When a widget's palette changes, it resolves its entries against its parent widget, or if it doesn't have a parent widget, it resolves against the scene. It then sends itself a PaletteChange event, and notifies all its descendants so they can resolve their palettes as well.
By default, this property contains the application's default palette.
Access functions:
QPalette | palette() const |
void | setPalette(const QPalette &palette) |
See also QApplication::palette(), QGraphicsScene::palette, and QPalette::resolve().
Sourcepub unsafe fn qt_metacall(
&self,
arg1: Call,
arg2: c_int,
arg3: *mut *mut c_void,
) -> c_int
pub unsafe fn qt_metacall( &self, arg1: Call, arg2: c_int, arg3: *mut *mut c_void, ) -> c_int
Calls C++ function: virtual int QGraphicsWidget::qt_metacall(QMetaObject::Call arg1, int arg2, void** arg3)
.
Sourcepub unsafe fn qt_metacast(&self, arg1: *const c_char) -> *mut c_void
pub unsafe fn qt_metacast(&self, arg1: *const c_char) -> *mut c_void
Calls C++ function: virtual void* QGraphicsWidget::qt_metacast(const char* arg1)
.
Sourcepub unsafe fn rect(&self) -> CppBox<QRectF>
pub unsafe fn rect(&self) -> CppBox<QRectF>
Sourcepub unsafe fn release_shortcut(&self, id: c_int)
pub unsafe fn release_shortcut(&self, id: c_int)
Removes the shortcut with the given id from Qt's shortcut system. The widget will no longer receive QEvent::Shortcut events for the shortcut's key sequence (unless it has other shortcuts with the same key sequence).
Calls C++ function: void QGraphicsWidget::releaseShortcut(int id)
.
Removes the shortcut with the given id from Qt’s shortcut system. The widget will no longer receive QEvent::Shortcut events for the shortcut’s key sequence (unless it has other shortcuts with the same key sequence).
Warning: You should not normally need to use this function since Qt's shortcut system removes shortcuts automatically when their parent widget is destroyed. It is best to use QAction or QShortcut to handle shortcuts, since they are easier to use than this low-level function. Note also that this is an expensive operation.
This function was introduced in Qt 4.5.
See also grabShortcut(), setShortcutEnabled(), and QWidget::releaseShortcut().
Sourcepub unsafe fn remove_action(&self, action: impl CastInto<Ptr<QAction>>)
pub unsafe fn remove_action(&self, action: impl CastInto<Ptr<QAction>>)
Removes the action action from this widget's list of actions.
Calls C++ function: void QGraphicsWidget::removeAction(QAction* action)
.
Removes the action action from this widget’s list of actions.
This function was introduced in Qt 4.5.
See also insertAction(), actions(), insertAction(), and QWidget::removeAction().
Sourcepub unsafe fn resize_1a(&self, size: impl CastInto<Ref<QSizeF>>)
pub unsafe fn resize_1a(&self, size: impl CastInto<Ref<QSizeF>>)
This property holds the size of the widget
Calls C++ function: void QGraphicsWidget::resize(const QSizeF& size)
.
This property holds the size of the widget
Calling resize() resizes the widget to a size bounded by minimumSize() and maximumSize(). This property only affects the widget's width and height (e.g., its right and bottom edges); the widget's position and top-left corner remains unaffected.
Resizing a widget triggers the widget to immediately receive a GraphicsSceneResize event with the widget's old and new size. If the widget has a layout assigned when this event arrives, the layout will be activated and it will automatically update any child widgets's geometry.
This property does not affect any layout of the parent widget. If the widget itself is managed by a parent layout; e.g., it has a parent widget with a layout assigned, that layout will not activate.
By default, this property contains a size with zero width and height.
Access functions:
QSizeF | size() const |
void | resize(const QSizeF &size) |
void | resize(qreal w, qreal h) |
Notifier signal:
void | geometryChanged() |
See also setGeometry(), QGraphicsSceneResizeEvent, and QGraphicsLayout.
Sourcepub unsafe fn resize_2a(&self, w: c_double, h: c_double)
pub unsafe fn resize_2a(&self, w: c_double, h: c_double)
This property holds the size of the widget
Calls C++ function: void QGraphicsWidget::resize(double w, double h)
.
This property holds the size of the widget
Calling resize() resizes the widget to a size bounded by minimumSize() and maximumSize(). This property only affects the widget's width and height (e.g., its right and bottom edges); the widget's position and top-left corner remains unaffected.
Resizing a widget triggers the widget to immediately receive a GraphicsSceneResize event with the widget's old and new size. If the widget has a layout assigned when this event arrives, the layout will be activated and it will automatically update any child widgets's geometry.
This property does not affect any layout of the parent widget. If the widget itself is managed by a parent layout; e.g., it has a parent widget with a layout assigned, that layout will not activate.
By default, this property contains a size with zero width and height.
Access functions:
QSizeF | size() const |
void | resize(const QSizeF &size) |
void | resize(qreal w, qreal h) |
Notifier signal:
void | geometryChanged() |
See also setGeometry(), QGraphicsSceneResizeEvent, and QGraphicsLayout.
Sourcepub unsafe fn set_attribute_2a(&self, attribute: WidgetAttribute, on: bool)
pub unsafe fn set_attribute_2a(&self, attribute: WidgetAttribute, on: bool)
If on is true, this function enables attribute; otherwise attribute is disabled.
Calls C++ function: void QGraphicsWidget::setAttribute(Qt::WidgetAttribute attribute, bool on = …)
.
If on is true, this function enables attribute; otherwise attribute is disabled.
See the class documentation for QGraphicsWidget for a complete list of which attributes are supported, and what they are for.
See also testAttribute() and QWidget::setAttribute().
Sourcepub unsafe fn set_attribute_1a(&self, attribute: WidgetAttribute)
pub unsafe fn set_attribute_1a(&self, attribute: WidgetAttribute)
If on is true, this function enables attribute; otherwise attribute is disabled.
Calls C++ function: void QGraphicsWidget::setAttribute(Qt::WidgetAttribute attribute)
.
If on is true, this function enables attribute; otherwise attribute is disabled.
See the class documentation for QGraphicsWidget for a complete list of which attributes are supported, and what they are for.
See also testAttribute() and QWidget::setAttribute().
Sourcepub unsafe fn set_auto_fill_background(&self, enabled: bool)
pub unsafe fn set_auto_fill_background(&self, enabled: bool)
This property holds whether the widget background is filled automatically
Calls C++ function: void QGraphicsWidget::setAutoFillBackground(bool enabled)
.
This property holds whether the widget background is filled automatically
If enabled, this property will cause Qt to fill the background of the widget before invoking the paint() method. The color used is defined by the QPalette::Window color role from the widget's palette.
In addition, Windows are always filled with QPalette::Window, unless the WA_OpaquePaintEvent or WA_NoSystemBackground attributes are set.
By default, this property is false
.
This property was introduced in Qt 4.7.
Access functions:
bool | autoFillBackground() const |
void | setAutoFillBackground(bool enabled) |
See also Qt::WA_OpaquePaintEvent and Qt::WA_NoSystemBackground.
Sourcepub unsafe fn set_contents_margins_4a(
&self,
left: c_double,
top: c_double,
right: c_double,
bottom: c_double,
)
pub unsafe fn set_contents_margins_4a( &self, left: c_double, top: c_double, right: c_double, bottom: c_double, )
Sets the widget's contents margins to left, top, right and bottom.
Calls C++ function: void QGraphicsWidget::setContentsMargins(double left, double top, double right, double bottom)
.
Sets the widget’s contents margins to left, top, right and bottom.
Contents margins are used by the assigned layout to define the placement of subwidgets and layouts. Margins are particularly useful for widgets that constrain subwidgets to only a section of its own geometry. For example, a group box with a layout will place subwidgets inside its frame, but below the title.
Changing a widget's contents margins will always trigger an update(), and any assigned layout will be activated automatically. The widget will then receive a ContentsRectChange event.
See also getContentsMargins() and setGeometry().
Sourcepub unsafe fn set_contents_margins_1a(
&self,
margins: impl CastInto<Ref<QMarginsF>>,
)
Available on cpp_lib_version="5.14.0"
only.
pub unsafe fn set_contents_margins_1a( &self, margins: impl CastInto<Ref<QMarginsF>>, )
cpp_lib_version="5.14.0"
only.Sets the widget's contents margins to margins.
Calls C++ function: void QGraphicsWidget::setContentsMargins(QMarginsF margins)
.
Sets the widget’s contents margins to margins.
Contents margins are used by the assigned layout to define the placement of subwidgets and layouts. Margins are particularly useful for widgets that constrain subwidgets to only a section of its own geometry. For example, a group box with a layout will place subwidgets inside its frame, but below the title.
Changing a widget's contents margins will always trigger an update(), and any assigned layout will be activated automatically. The widget will then receive a ContentsRectChange event.
This function was introduced in Qt 5.14.
See also getContentsMargins() and setGeometry().
Sourcepub unsafe fn set_focus_policy(&self, policy: FocusPolicy)
pub unsafe fn set_focus_policy(&self, policy: FocusPolicy)
This property holds the way the widget accepts keyboard focus
Calls C++ function: void QGraphicsWidget::setFocusPolicy(Qt::FocusPolicy policy)
.
This property holds the way the widget accepts keyboard focus
The focus policy is Qt::TabFocus if the widget accepts keyboard focus by tabbing, Qt::ClickFocus if the widget accepts focus by clicking, Qt::StrongFocus if it accepts both, and Qt::NoFocus (the default) if it does not accept focus at all.
You must enable keyboard focus for a widget if it processes keyboard events. This is normally done from the widget's constructor. For instance, the QLineEdit constructor calls setFocusPolicy(Qt::StrongFocus).
If you enable a focus policy (i.e., not Qt::NoFocus), QGraphicsWidget will automatically enable the ItemIsFocusable flag. Setting Qt::NoFocus on a widget will clear the ItemIsFocusable flag. If the widget currently has keyboard focus, the widget will automatically lose focus.
Access functions:
Qt::FocusPolicy | focusPolicy() const |
void | setFocusPolicy(Qt::FocusPolicy policy) |
See also focusInEvent(), focusOutEvent(), keyPressEvent(), keyReleaseEvent(), and enabled.
Sourcepub unsafe fn set_font(&self, font: impl CastInto<Ref<QFont>>)
pub unsafe fn set_font(&self, font: impl CastInto<Ref<QFont>>)
This property holds the widgets' font
Calls C++ function: void QGraphicsWidget::setFont(const QFont& font)
.
This property holds the widgets’ font
This property provides the widget's font.
QFont consists of font properties that have been explicitly defined and properties implicitly inherited from the widget's parent. Hence, font() can return a different font compared to the one set with setFont(). This scheme allows you to define single entries in a font without affecting the font's inherited entries.
When a widget's font changes, it resolves its entries against its parent widget. If the widget does not have a parent widget, it resolves its entries against the scene. The widget then sends itself a FontChange event and notifies all its descendants so that they can resolve their fonts as well.
By default, this property contains the application's default font.
Access functions:
QFont | font() const |
void | setFont(const QFont &font) |
See also QApplication::font(), QGraphicsScene::font, and QFont::resolve().
Sourcepub unsafe fn set_geometry_1a(&self, rect: impl CastInto<Ref<QRectF>>)
pub unsafe fn set_geometry_1a(&self, rect: impl CastInto<Ref<QRectF>>)
This property holds the geometry of the widget
Calls C++ function: virtual void QGraphicsWidget::setGeometry(const QRectF& rect)
.
This property holds the geometry of the widget
Sets the item's geometry to rect. The item's position and size are modified as a result of calling this function. The item is first moved, then resized.
A side effect of calling this function is that the widget will receive a move event and a resize event. Also, if the widget has a layout assigned, the layout will activate.
Access functions:
virtual void | setGeometry(const QRectF &rect) |
void | setGeometry(qreal x, qreal y, qreal w, qreal h) |
Notifier signal:
void | geometryChanged() |
Sourcepub unsafe fn set_geometry_4a(
&self,
x: c_double,
y: c_double,
w: c_double,
h: c_double,
)
pub unsafe fn set_geometry_4a( &self, x: c_double, y: c_double, w: c_double, h: c_double, )
This property holds the geometry of the widget
Calls C++ function: void QGraphicsWidget::setGeometry(double x, double y, double w, double h)
.
This property holds the geometry of the widget
Sets the item's geometry to rect. The item's position and size are modified as a result of calling this function. The item is first moved, then resized.
A side effect of calling this function is that the widget will receive a move event and a resize event. Also, if the widget has a layout assigned, the layout will activate.
Access functions:
virtual void | setGeometry(const QRectF &rect) |
void | setGeometry(qreal x, qreal y, qreal w, qreal h) |
Notifier signal:
void | geometryChanged() |
Sourcepub unsafe fn set_layout(&self, layout: impl CastInto<Ptr<QGraphicsLayout>>)
pub unsafe fn set_layout(&self, layout: impl CastInto<Ptr<QGraphicsLayout>>)
Sets the layout for this widget to layout. Any existing layout manager is deleted before the new layout is assigned. If layout is 0, the widget is left without a layout. Existing subwidgets' geometries will remain unaffected.
Calls C++ function: void QGraphicsWidget::setLayout(QGraphicsLayout* layout)
.
Sets the layout for this widget to layout. Any existing layout manager is deleted before the new layout is assigned. If layout is 0, the widget is left without a layout. Existing subwidgets’ geometries will remain unaffected.
All widgets that are currently managed by layout or all of its sublayouts, are automatically reparented to this item. The layout is then invalidated, and the child widget geometries are adjusted according to this item's geometry() and contentsMargins(). Children who are not explicitly managed by layout remain unaffected by the layout after it has been assigned to this widget.
QGraphicsWidget takes ownership of layout.
Note: Setter function for property layout.
See also layout(), QGraphicsLinearLayout::addItem(), and QGraphicsLayout::invalidate().
Sourcepub unsafe fn set_layout_direction(&self, direction: LayoutDirection)
pub unsafe fn set_layout_direction(&self, direction: LayoutDirection)
This property holds the layout direction for this widget.
Calls C++ function: void QGraphicsWidget::setLayoutDirection(Qt::LayoutDirection direction)
.
This property holds the layout direction for this widget.
This property modifies this widget's and all of its descendants' Qt::WA_RightToLeft attribute. It also sets this widget's Qt::WA_SetLayoutDirection attribute.
The widget's layout direction determines the order in which the layout manager horizontally arranges subwidgets of this widget. The default value depends on the language and locale of the application, and is typically in the same direction as words are read and written. With Qt::LeftToRight, the layout starts placing subwidgets from the left side of this widget towards the right. Qt::RightToLeft does the opposite - the layout will place widgets starting from the right edge moving towards the left.
Subwidgets inherit their layout direction from the parent. Top-level widget items inherit their layout direction from QGraphicsScene::layoutDirection. If you change a widget's layout direction by calling setLayoutDirection(), the widget will send itself a LayoutDirectionChange event, and then propagate the new layout direction to all its descendants.
Access functions:
Qt::LayoutDirection | layoutDirection() const |
void | setLayoutDirection(Qt::LayoutDirection direction) |
void | unsetLayoutDirection() |
See also QWidget::layoutDirection and QApplication::layoutDirection.
Sourcepub unsafe fn set_palette(&self, palette: impl CastInto<Ref<QPalette>>)
pub unsafe fn set_palette(&self, palette: impl CastInto<Ref<QPalette>>)
This property holds the widget's palette
Calls C++ function: void QGraphicsWidget::setPalette(const QPalette& palette)
.
This property holds the widget’s palette
This property provides the widget's palette. The palette provides colors and brushes for color groups (e.g., QPalette::Button) and states (e.g., QPalette::Inactive), loosely defining the general look of the widget and its children.
QPalette consists of color groups that have been explicitly defined, and groups that are implicitly inherited from the widget's parent. Because of this, palette() can return a different palette than what has been set with setPalette(). This scheme allows you to define single entries in a palette without affecting the palette's inherited entries.
When a widget's palette changes, it resolves its entries against its parent widget, or if it doesn't have a parent widget, it resolves against the scene. It then sends itself a PaletteChange event, and notifies all its descendants so they can resolve their palettes as well.
By default, this property contains the application's default palette.
Access functions:
QPalette | palette() const |
void | setPalette(const QPalette &palette) |
See also QApplication::palette(), QGraphicsScene::palette, and QPalette::resolve().
Sourcepub unsafe fn set_shortcut_auto_repeat_2a(&self, id: c_int, enabled: bool)
pub unsafe fn set_shortcut_auto_repeat_2a(&self, id: c_int, enabled: bool)
If enabled is true, auto repeat of the shortcut with the given id is enabled; otherwise it is disabled.
Calls C++ function: void QGraphicsWidget::setShortcutAutoRepeat(int id, bool enabled = …)
.
If enabled is true, auto repeat of the shortcut with the given id is enabled; otherwise it is disabled.
This function was introduced in Qt 4.5.
See also grabShortcut(), releaseShortcut(), and QWidget::setShortcutAutoRepeat().
Sourcepub unsafe fn set_shortcut_auto_repeat_1a(&self, id: c_int)
pub unsafe fn set_shortcut_auto_repeat_1a(&self, id: c_int)
If enabled is true, auto repeat of the shortcut with the given id is enabled; otherwise it is disabled.
Calls C++ function: void QGraphicsWidget::setShortcutAutoRepeat(int id)
.
If enabled is true, auto repeat of the shortcut with the given id is enabled; otherwise it is disabled.
This function was introduced in Qt 4.5.
See also grabShortcut(), releaseShortcut(), and QWidget::setShortcutAutoRepeat().
Sourcepub unsafe fn set_shortcut_enabled_2a(&self, id: c_int, enabled: bool)
pub unsafe fn set_shortcut_enabled_2a(&self, id: c_int, enabled: bool)
If enabled is true, the shortcut with the given id is enabled; otherwise the shortcut is disabled.
Calls C++ function: void QGraphicsWidget::setShortcutEnabled(int id, bool enabled = …)
.
If enabled is true, the shortcut with the given id is enabled; otherwise the shortcut is disabled.
Warning: You should not normally need to use this function since Qt's shortcut system enables/disables shortcuts automatically as widgets become hidden/visible and gain or lose focus. It is best to use QAction or QShortcut to handle shortcuts, since they are easier to use than this low-level function.
This function was introduced in Qt 4.5.
See also grabShortcut(), releaseShortcut(), and QWidget::setShortcutEnabled().
Sourcepub unsafe fn set_shortcut_enabled_1a(&self, id: c_int)
pub unsafe fn set_shortcut_enabled_1a(&self, id: c_int)
If enabled is true, the shortcut with the given id is enabled; otherwise the shortcut is disabled.
Calls C++ function: void QGraphicsWidget::setShortcutEnabled(int id)
.
If enabled is true, the shortcut with the given id is enabled; otherwise the shortcut is disabled.
Warning: You should not normally need to use this function since Qt's shortcut system enables/disables shortcuts automatically as widgets become hidden/visible and gain or lose focus. It is best to use QAction or QShortcut to handle shortcuts, since they are easier to use than this low-level function.
This function was introduced in Qt 4.5.
See also grabShortcut(), releaseShortcut(), and QWidget::setShortcutEnabled().
Sourcepub unsafe fn set_style(&self, style: impl CastInto<Ptr<QStyle>>)
pub unsafe fn set_style(&self, style: impl CastInto<Ptr<QStyle>>)
Sets the widget's style to style. QGraphicsWidget does not take ownership of style.
Calls C++ function: void QGraphicsWidget::setStyle(QStyle* style)
.
Sets the widget’s style to style. QGraphicsWidget does not take ownership of style.
If no style is assigned, or style is 0, the widget will use QGraphicsScene::style() (if this has been set). Otherwise the widget will use QApplication::style().
This function sets the Qt::WA_SetStyle attribute if style is not 0; otherwise it clears the attribute.
See also style().
Sourcepub unsafe fn set_window_flags(&self, w_flags: QFlags<WindowType>)
pub unsafe fn set_window_flags(&self, w_flags: QFlags<WindowType>)
This property holds the widget's window flags
Calls C++ function: void QGraphicsWidget::setWindowFlags(QFlags<Qt::WindowType> wFlags)
.
This property holds the widget’s window flags
Window flags are a combination of a window type (e.g., Qt::Dialog) and several flags giving hints on the behavior of the window. The behavior is platform-dependent.
By default, this property contains no window flags.
Windows are panels. If you set the Qt::Window flag, the ItemIsPanel flag will be set automatically. If you clear the Qt::Window flag, the ItemIsPanel flag is also cleared. Note that the ItemIsPanel flag can be set independently of Qt::Window.
Access functions:
Qt::WindowFlags | windowFlags() const |
void | setWindowFlags(Qt::WindowFlags wFlags) |
Sourcepub unsafe fn set_window_frame_margins_4a(
&self,
left: c_double,
top: c_double,
right: c_double,
bottom: c_double,
)
pub unsafe fn set_window_frame_margins_4a( &self, left: c_double, top: c_double, right: c_double, bottom: c_double, )
Sets the widget's window frame margins to left, top, right and bottom. The default frame margins are provided by the style, and they depend on the current window flags.
Calls C++ function: void QGraphicsWidget::setWindowFrameMargins(double left, double top, double right, double bottom)
.
Sets the widget’s window frame margins to left, top, right and bottom. The default frame margins are provided by the style, and they depend on the current window flags.
If you would like to draw your own window decoration, you can set your own frame margins to override the default margins.
See also unsetWindowFrameMargins(), getWindowFrameMargins(), and windowFrameRect().
Sourcepub unsafe fn set_window_frame_margins_1a(
&self,
margins: impl CastInto<Ref<QMarginsF>>,
)
Available on cpp_lib_version="5.14.0"
only.
pub unsafe fn set_window_frame_margins_1a( &self, margins: impl CastInto<Ref<QMarginsF>>, )
cpp_lib_version="5.14.0"
only.Sets the widget's window frame margins to margins. The default frame margins are provided by the style, and they depend on the current window flags.
Calls C++ function: void QGraphicsWidget::setWindowFrameMargins(QMarginsF margins)
.
Sets the widget’s window frame margins to margins. The default frame margins are provided by the style, and they depend on the current window flags.
If you would like to draw your own window decoration, you can set your own frame margins to override the default margins.
This function was introduced in Qt 5.14.
See also unsetWindowFrameMargins(), getWindowFrameMargins(), and windowFrameRect().
Sourcepub unsafe fn set_window_title(&self, title: impl CastInto<Ref<QString>>)
pub unsafe fn set_window_title(&self, title: impl CastInto<Ref<QString>>)
This property holds the window title (caption).
Calls C++ function: void QGraphicsWidget::setWindowTitle(const QString& title)
.
This property holds the window title (caption).
This property is only used for windows.
By default, if no title has been set, this property contains an empty string.
Access functions:
QString | windowTitle() const |
void | setWindowTitle(const QString &title) |
Sourcepub unsafe fn shape(&self) -> CppBox<QPainterPath>
pub unsafe fn shape(&self) -> CppBox<QPainterPath>
Reimplemented from QGraphicsItem::shape().
Calls C++ function: virtual QPainterPath QGraphicsWidget::shape() const
.
Reimplemented from QGraphicsItem::shape().
Sourcepub unsafe fn size(&self) -> CppBox<QSizeF>
pub unsafe fn size(&self) -> CppBox<QSizeF>
This property holds the size of the widget
Calls C++ function: QSizeF QGraphicsWidget::size() const
.
This property holds the size of the widget
Calling resize() resizes the widget to a size bounded by minimumSize() and maximumSize(). This property only affects the widget's width and height (e.g., its right and bottom edges); the widget's position and top-left corner remains unaffected.
Resizing a widget triggers the widget to immediately receive a GraphicsSceneResize event with the widget's old and new size. If the widget has a layout assigned when this event arrives, the layout will be activated and it will automatically update any child widgets's geometry.
This property does not affect any layout of the parent widget. If the widget itself is managed by a parent layout; e.g., it has a parent widget with a layout assigned, that layout will not activate.
By default, this property contains a size with zero width and height.
Access functions:
QSizeF | size() const |
void | resize(const QSizeF &size) |
void | resize(qreal w, qreal h) |
Notifier signal:
void | geometryChanged() |
See also setGeometry(), QGraphicsSceneResizeEvent, and QGraphicsLayout.
Sourcepub unsafe fn style(&self) -> QPtr<QStyle>
pub unsafe fn style(&self) -> QPtr<QStyle>
Returns a pointer to the widget's style. If this widget does not have any explicitly assigned style, the scene's style is returned instead. In turn, if the scene does not have any assigned style, this function returns QApplication::style().
Calls C++ function: QStyle* QGraphicsWidget::style() const
.
Returns a pointer to the widget’s style. If this widget does not have any explicitly assigned style, the scene’s style is returned instead. In turn, if the scene does not have any assigned style, this function returns QApplication::style().
See also setStyle().
Sourcepub unsafe fn test_attribute(&self, attribute: WidgetAttribute) -> bool
pub unsafe fn test_attribute(&self, attribute: WidgetAttribute) -> bool
Returns true
if attribute is enabled for this widget; otherwise, returns false
.
Calls C++ function: bool QGraphicsWidget::testAttribute(Qt::WidgetAttribute attribute) const
.
Returns true
if attribute is enabled for this widget; otherwise, returns false
.
See also setAttribute().
Sourcepub unsafe fn type_(&self) -> c_int
pub unsafe fn type_(&self) -> c_int
Reimplemented from QGraphicsItem::type().
Calls C++ function: virtual int QGraphicsWidget::type() const
.
Reimplemented from QGraphicsItem::type().
Sourcepub unsafe fn unset_layout_direction(&self)
pub unsafe fn unset_layout_direction(&self)
This property holds the layout direction for this widget.
Calls C++ function: void QGraphicsWidget::unsetLayoutDirection()
.
This property holds the layout direction for this widget.
This property modifies this widget's and all of its descendants' Qt::WA_RightToLeft attribute. It also sets this widget's Qt::WA_SetLayoutDirection attribute.
The widget's layout direction determines the order in which the layout manager horizontally arranges subwidgets of this widget. The default value depends on the language and locale of the application, and is typically in the same direction as words are read and written. With Qt::LeftToRight, the layout starts placing subwidgets from the left side of this widget towards the right. Qt::RightToLeft does the opposite - the layout will place widgets starting from the right edge moving towards the left.
Subwidgets inherit their layout direction from the parent. Top-level widget items inherit their layout direction from QGraphicsScene::layoutDirection. If you change a widget's layout direction by calling setLayoutDirection(), the widget will send itself a LayoutDirectionChange event, and then propagate the new layout direction to all its descendants.
Access functions:
Qt::LayoutDirection | layoutDirection() const |
void | setLayoutDirection(Qt::LayoutDirection direction) |
void | unsetLayoutDirection() |
See also QWidget::layoutDirection and QApplication::layoutDirection.
Sourcepub unsafe fn unset_window_frame_margins(&self)
pub unsafe fn unset_window_frame_margins(&self)
Resets the window frame margins to the default value, provided by the style.
Calls C++ function: void QGraphicsWidget::unsetWindowFrameMargins()
.
Resets the window frame margins to the default value, provided by the style.
See also setWindowFrameMargins(), getWindowFrameMargins(), and windowFrameRect().
Sourcepub unsafe fn window_flags(&self) -> QFlags<WindowType>
pub unsafe fn window_flags(&self) -> QFlags<WindowType>
This property holds the widget's window flags
Calls C++ function: QFlags<Qt::WindowType> QGraphicsWidget::windowFlags() const
.
This property holds the widget’s window flags
Window flags are a combination of a window type (e.g., Qt::Dialog) and several flags giving hints on the behavior of the window. The behavior is platform-dependent.
By default, this property contains no window flags.
Windows are panels. If you set the Qt::Window flag, the ItemIsPanel flag will be set automatically. If you clear the Qt::Window flag, the ItemIsPanel flag is also cleared. Note that the ItemIsPanel flag can be set independently of Qt::Window.
Access functions:
Qt::WindowFlags | windowFlags() const |
void | setWindowFlags(Qt::WindowFlags wFlags) |
Sourcepub unsafe fn window_frame_geometry(&self) -> CppBox<QRectF>
pub unsafe fn window_frame_geometry(&self) -> CppBox<QRectF>
Returns the widget's geometry in parent coordinates including any window frame.
Calls C++ function: QRectF QGraphicsWidget::windowFrameGeometry() const
.
Returns the widget’s geometry in parent coordinates including any window frame.
See also windowFrameRect(), getWindowFrameMargins(), and setWindowFrameMargins().
Sourcepub unsafe fn window_frame_rect(&self) -> CppBox<QRectF>
pub unsafe fn window_frame_rect(&self) -> CppBox<QRectF>
Returns the widget's local rect including any window frame.
Calls C++ function: QRectF QGraphicsWidget::windowFrameRect() const
.
Returns the widget’s local rect including any window frame.
See also windowFrameGeometry(), getWindowFrameMargins(), and setWindowFrameMargins().
Sourcepub unsafe fn window_title(&self) -> CppBox<QString>
pub unsafe fn window_title(&self) -> CppBox<QString>
This property holds the window title (caption).
Calls C++ function: QString QGraphicsWidget::windowTitle() const
.
This property holds the window title (caption).
This property is only used for windows.
By default, if no title has been set, this property contains an empty string.
Access functions:
QString | windowTitle() const |
void | setWindowTitle(const QString &title) |
Sourcepub unsafe fn window_type(&self) -> WindowType
pub unsafe fn window_type(&self) -> WindowType
Returns the widgets window type.
Calls C++ function: Qt::WindowType QGraphicsWidget::windowType() const
.
Returns the widgets window type.
See also windowFlags(), isWindow(), and isPanel().
Methods from Deref<Target = QGraphicsObject>§
Sourcepub fn slot_update_micro_focus(&self) -> Receiver<()>
pub fn slot_update_micro_focus(&self) -> Receiver<()>
Updates the item's micro focus. This is slot for convenience.
Returns a built-in Qt slot QGraphicsObject::updateMicroFocus
that can be passed to qt_core::Signal::connect
.
Updates the item’s micro focus. This is slot for convenience.
This function was introduced in Qt 4.7.
See also QInputMethod.
Sourcepub fn parent_changed(&self) -> Signal<()>
pub fn parent_changed(&self) -> Signal<()>
This signal gets emitted whenever the parent of the item changes
Returns a built-in Qt signal QGraphicsObject::parentChanged
that can be passed to qt_core::Signal::connect
.
This signal gets emitted whenever the parent of the item changes
Note: Notifier signal for property parent.
Sourcepub fn opacity_changed(&self) -> Signal<()>
pub fn opacity_changed(&self) -> Signal<()>
This signal gets emitted whenever the opacity of the item changes
Returns a built-in Qt signal QGraphicsObject::opacityChanged
that can be passed to qt_core::Signal::connect
.
This signal gets emitted whenever the opacity of the item changes
Note: Notifier signal for property opacity.
See also QGraphicsItem::opacity().
Sourcepub fn visible_changed(&self) -> Signal<()>
pub fn visible_changed(&self) -> Signal<()>
This signal gets emitted whenever the visibility of the item changes
Returns a built-in Qt signal QGraphicsObject::visibleChanged
that can be passed to qt_core::Signal::connect
.
Sourcepub fn enabled_changed(&self) -> Signal<()>
pub fn enabled_changed(&self) -> Signal<()>
This signal gets emitted whenever the item get's enabled or disabled.
Returns a built-in Qt signal QGraphicsObject::enabledChanged
that can be passed to qt_core::Signal::connect
.
Sourcepub fn x_changed(&self) -> Signal<()>
pub fn x_changed(&self) -> Signal<()>
This signal gets emitted whenever the x position of the item changes
Returns a built-in Qt signal QGraphicsObject::xChanged
that can be passed to qt_core::Signal::connect
.
Sourcepub fn y_changed(&self) -> Signal<()>
pub fn y_changed(&self) -> Signal<()>
This signal gets emitted whenever the y position of the item changes.
Returns a built-in Qt signal QGraphicsObject::yChanged
that can be passed to qt_core::Signal::connect
.
Sourcepub fn z_changed(&self) -> Signal<()>
pub fn z_changed(&self) -> Signal<()>
This signal gets emitted whenever the z value of the item changes.
Returns a built-in Qt signal QGraphicsObject::zChanged
that can be passed to qt_core::Signal::connect
.
Sourcepub fn rotation_changed(&self) -> Signal<()>
pub fn rotation_changed(&self) -> Signal<()>
This signal gets emitted whenever the roation of the item changes.
Returns a built-in Qt signal QGraphicsObject::rotationChanged
that can be passed to qt_core::Signal::connect
.
This signal gets emitted whenever the roation of the item changes.
Note: Notifier signal for property rotation.
Sourcepub fn scale_changed(&self) -> Signal<()>
pub fn scale_changed(&self) -> Signal<()>
This signal is emitted when the scale of the item changes.
Returns a built-in Qt signal QGraphicsObject::scaleChanged
that can be passed to qt_core::Signal::connect
.
This signal is emitted when the scale of the item changes.
Note: Notifier signal for property scale.
Sourcepub fn children_changed(&self) -> Signal<()>
pub fn children_changed(&self) -> Signal<()>
Returns a built-in Qt signal QGraphicsObject::childrenChanged
that can be passed to qt_core::Signal::connect
.
Sourcepub fn width_changed(&self) -> Signal<()>
pub fn width_changed(&self) -> Signal<()>
Returns a built-in Qt signal QGraphicsObject::widthChanged
that can be passed to qt_core::Signal::connect
.
Sourcepub fn height_changed(&self) -> Signal<()>
pub fn height_changed(&self) -> Signal<()>
Returns a built-in Qt signal QGraphicsObject::heightChanged
that can be passed to qt_core::Signal::connect
.
Sourcepub unsafe fn grab_gesture_2a(
&self,
type_: GestureType,
flags: QFlags<GestureFlag>,
)
pub unsafe fn grab_gesture_2a( &self, type_: GestureType, flags: QFlags<GestureFlag>, )
Subscribes the graphics object to the given gesture with specific flags.
Calls C++ function: void QGraphicsObject::grabGesture(Qt::GestureType type, QFlags<Qt::GestureFlag> flags = …)
.
Subscribes the graphics object to the given gesture with specific flags.
See also ungrabGesture() and QGestureEvent.
Sourcepub unsafe fn grab_gesture_1a(&self, type_: GestureType)
pub unsafe fn grab_gesture_1a(&self, type_: GestureType)
Subscribes the graphics object to the given gesture with specific flags.
Calls C++ function: void QGraphicsObject::grabGesture(Qt::GestureType type)
.
Subscribes the graphics object to the given gesture with specific flags.
See also ungrabGesture() and QGestureEvent.
Sourcepub unsafe fn meta_object(&self) -> Ptr<QMetaObject>
pub unsafe fn meta_object(&self) -> Ptr<QMetaObject>
Calls C++ function: virtual const QMetaObject* QGraphicsObject::metaObject() const
.
Sourcepub unsafe fn qt_metacall(
&self,
arg1: Call,
arg2: c_int,
arg3: *mut *mut c_void,
) -> c_int
pub unsafe fn qt_metacall( &self, arg1: Call, arg2: c_int, arg3: *mut *mut c_void, ) -> c_int
Calls C++ function: virtual int QGraphicsObject::qt_metacall(QMetaObject::Call arg1, int arg2, void** arg3)
.
Sourcepub unsafe fn qt_metacast(&self, arg1: *const c_char) -> *mut c_void
pub unsafe fn qt_metacast(&self, arg1: *const c_char) -> *mut c_void
Calls C++ function: virtual void* QGraphicsObject::qt_metacast(const char* arg1)
.
Sourcepub unsafe fn ungrab_gesture(&self, type_: GestureType)
pub unsafe fn ungrab_gesture(&self, type_: GestureType)
Unsubscribes the graphics object from the given gesture.
Calls C++ function: void QGraphicsObject::ungrabGesture(Qt::GestureType type)
.
Unsubscribes the graphics object from the given gesture.
See also grabGesture() and QGestureEvent.
Methods from Deref<Target = QObject>§
Sourcepub unsafe fn find_child<T>(
&self,
name: &str,
) -> Result<QPtr<T>, FindChildError>
pub unsafe fn find_child<T>( &self, name: &str, ) -> Result<QPtr<T>, FindChildError>
Finds a child of self
with the specified object name
and casts it to type T
.
The search is performed recursively. If there is more than one child matching the search, the most direct ancestor is returned. If there are several direct ancestors, it is undefined which one will be returned.
Returns an error if there is no child object with object name name
or
the found object cannot be cast to T
.
Sourcepub fn destroyed(&self) -> Signal<(*mut QObject,)>
pub fn destroyed(&self) -> Signal<(*mut QObject,)>
This signal is emitted immediately before the object obj is destroyed, and can not be blocked.
Returns a built-in Qt signal QObject::destroyed
that can be passed to qt_core::Signal::connect
.
This signal is emitted immediately before the object obj is destroyed, and can not be blocked.
All the objects's children are destroyed immediately after this signal is emitted.
See also deleteLater() and QPointer.
Sourcepub fn object_name_changed(&self) -> Signal<(*const QString,)>
pub fn object_name_changed(&self) -> Signal<(*const QString,)>
This signal is emitted after the object's name has been changed. The new object name is passed as objectName.
Returns a built-in Qt signal QObject::objectNameChanged
that can be passed to qt_core::Signal::connect
.
This signal is emitted after the object’s name has been changed. The new object name is passed as objectName.
Note: This is a private signal. It can be used in signal connections but cannot be emitted by the user.
Note: Notifier signal for property objectName.
See also QObject::objectName.
Sourcepub fn slot_delete_later(&self) -> Receiver<()>
pub fn slot_delete_later(&self) -> Receiver<()>
Schedules this object for deletion.
Returns a built-in Qt slot QObject::deleteLater
that can be passed to qt_core::Signal::connect
.
Schedules this object for deletion.
The object will be deleted when control returns to the event loop. If the event loop is not running when this function is called (e.g. deleteLater() is called on an object before QCoreApplication::exec()), the object will be deleted once the event loop is started. If deleteLater() is called after the main event loop has stopped, the object will not be deleted. Since Qt 4.8, if deleteLater() is called on an object that lives in a thread with no running event loop, the object will be destroyed when the thread finishes.
Note that entering and leaving a new event loop (e.g., by opening a modal dialog) will not perform the deferred deletion; for the object to be deleted, the control must return to the event loop from which deleteLater() was called.
Note: It is safe to call this function more than once; when the first deferred deletion event is delivered, any pending events for the object are removed from the event queue.
Sourcepub unsafe fn block_signals(&self, b: bool) -> bool
pub unsafe fn block_signals(&self, b: bool) -> bool
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). If block is false, no such blocking will occur.
Calls C++ function: bool QObject::blockSignals(bool b)
.
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). If block is false, no such blocking will occur.
The return value is the previous value of signalsBlocked().
Note that the destroyed() signal will be emitted even if the signals for this object have been blocked.
Signals emitted while being blocked are not buffered.
See also signalsBlocked() and QSignalBlocker.
Sourcepub unsafe fn children(&self) -> Ref<QListOfQObject>
pub unsafe fn children(&self) -> Ref<QListOfQObject>
Returns a list of child objects. The QObjectList class is defined in the <QObject>
header file as the following:
Calls C++ function: const QList<QObject*>& QObject::children() const
.
Returns a list of child objects. The QObjectList class is defined in the <QObject>
header file as the following:
typedef QList<QObject*> QObjectList;
The first child added is the first object in the list and the last child added is the last object in the list, i.e. new children are appended at the end.
Note that the list order changes when QWidget children are raised or lowered. A widget that is raised becomes the last object in the list, and a widget that is lowered becomes the first object in the list.
See also findChild(), findChildren(), parent(), and setParent().
Sourcepub unsafe fn delete_later(&self)
pub unsafe fn delete_later(&self)
Schedules this object for deletion.
Calls C++ function: [slot] void QObject::deleteLater()
.
Schedules this object for deletion.
The object will be deleted when control returns to the event loop. If the event loop is not running when this function is called (e.g. deleteLater() is called on an object before QCoreApplication::exec()), the object will be deleted once the event loop is started. If deleteLater() is called after the main event loop has stopped, the object will not be deleted. Since Qt 4.8, if deleteLater() is called on an object that lives in a thread with no running event loop, the object will be destroyed when the thread finishes.
Note that entering and leaving a new event loop (e.g., by opening a modal dialog) will not perform the deferred deletion; for the object to be deleted, the control must return to the event loop from which deleteLater() was called.
Note: It is safe to call this function more than once; when the first deferred deletion event is delivered, any pending events for the object are removed from the event queue.
Sourcepub unsafe fn disconnect_char_q_object_char(
&self,
signal: *const i8,
receiver: impl CastInto<Ptr<QObject>>,
member: *const i8,
) -> bool
pub unsafe fn disconnect_char_q_object_char( &self, signal: *const i8, receiver: impl CastInto<Ptr<QObject>>, member: *const i8, ) -> bool
This function overloads disconnect().
Calls C++ function: bool QObject::disconnect(const char* signal = …, const QObject* receiver = …, const char* member = …) const
.
This function overloads disconnect().
Disconnects signal from method of receiver.
A signal-slot connection is removed when either of the objects involved are destroyed.
Note: This function is thread-safe.
Sourcepub unsafe fn disconnect_q_object_char(
&self,
receiver: impl CastInto<Ptr<QObject>>,
member: *const i8,
) -> bool
pub unsafe fn disconnect_q_object_char( &self, receiver: impl CastInto<Ptr<QObject>>, member: *const i8, ) -> bool
This function overloads disconnect().
Calls C++ function: bool QObject::disconnect(const QObject* receiver, const char* member = …) const
.
This function overloads disconnect().
Disconnects all signals in this object from receiver's method.
A signal-slot connection is removed when either of the objects involved are destroyed.
Sourcepub unsafe fn disconnect_char_q_object(
&self,
signal: *const i8,
receiver: impl CastInto<Ptr<QObject>>,
) -> bool
pub unsafe fn disconnect_char_q_object( &self, signal: *const i8, receiver: impl CastInto<Ptr<QObject>>, ) -> bool
This function overloads disconnect().
Calls C++ function: bool QObject::disconnect(const char* signal = …, const QObject* receiver = …) const
.
This function overloads disconnect().
Disconnects signal from method of receiver.
A signal-slot connection is removed when either of the objects involved are destroyed.
Note: This function is thread-safe.
Sourcepub unsafe fn disconnect_char(&self, signal: *const i8) -> bool
pub unsafe fn disconnect_char(&self, signal: *const i8) -> bool
This function overloads disconnect().
Calls C++ function: bool QObject::disconnect(const char* signal = …) const
.
This function overloads disconnect().
Disconnects signal from method of receiver.
A signal-slot connection is removed when either of the objects involved are destroyed.
Note: This function is thread-safe.
Sourcepub unsafe fn disconnect(&self) -> bool
pub unsafe fn disconnect(&self) -> bool
This function overloads disconnect().
Calls C++ function: bool QObject::disconnect() const
.
This function overloads disconnect().
Disconnects signal from method of receiver.
A signal-slot connection is removed when either of the objects involved are destroyed.
Note: This function is thread-safe.
Sourcepub unsafe fn disconnect_q_object(
&self,
receiver: impl CastInto<Ptr<QObject>>,
) -> bool
pub unsafe fn disconnect_q_object( &self, receiver: impl CastInto<Ptr<QObject>>, ) -> bool
This function overloads disconnect().
Calls C++ function: bool QObject::disconnect(const QObject* receiver) const
.
This function overloads disconnect().
Disconnects all signals in this object from receiver's method.
A signal-slot connection is removed when either of the objects involved are destroyed.
Sourcepub unsafe fn dump_object_info_mut(&self)
pub unsafe fn dump_object_info_mut(&self)
Dumps information about signal connections, etc. for this object to the debug output.
Calls C++ function: void QObject::dumpObjectInfo()
.
Dumps information about signal connections, etc. for this object to the debug output.
Note: before Qt 5.9, this function was not const.
See also dumpObjectTree().
Sourcepub unsafe fn dump_object_info(&self)
pub unsafe fn dump_object_info(&self)
Dumps information about signal connections, etc. for this object to the debug output.
Calls C++ function: void QObject::dumpObjectInfo() const
.
Dumps information about signal connections, etc. for this object to the debug output.
Note: before Qt 5.9, this function was not const.
See also dumpObjectTree().
Sourcepub unsafe fn dump_object_tree_mut(&self)
pub unsafe fn dump_object_tree_mut(&self)
Dumps a tree of children to the debug output.
Calls C++ function: void QObject::dumpObjectTree()
.
Dumps a tree of children to the debug output.
Note: before Qt 5.9, this function was not const.
See also dumpObjectInfo().
Sourcepub unsafe fn dump_object_tree(&self)
pub unsafe fn dump_object_tree(&self)
Dumps a tree of children to the debug output.
Calls C++ function: void QObject::dumpObjectTree() const
.
Dumps a tree of children to the debug output.
Note: before Qt 5.9, this function was not const.
See also dumpObjectInfo().
Sourcepub unsafe fn dynamic_property_names(&self) -> CppBox<QListOfQByteArray>
pub unsafe fn dynamic_property_names(&self) -> CppBox<QListOfQByteArray>
Returns the names of all properties that were dynamically added to the object using setProperty().
Calls C++ function: QList<QByteArray> QObject::dynamicPropertyNames() const
.
Returns the names of all properties that were dynamically added to the object using setProperty().
This function was introduced in Qt 4.2.
Sourcepub unsafe fn eq(&self, p: impl CastInto<Ref<QPointerOfQObject>>) -> bool
pub unsafe fn eq(&self, p: impl CastInto<Ref<QPointerOfQObject>>) -> bool
Returns true
if c1 and c2 are the same Unicode character; otherwise returns false
.
Calls C++ function: bool operator==(QObject* o, const QPointer<QObject>& p)
.
Warning: no exact match found in C++ documentation. Below is the C++ documentation for bool operator==(QChar c1, QChar c2)
:
Returns true
if c1 and c2 are the same Unicode character; otherwise returns false
.
Sourcepub unsafe fn event(&self, event: impl CastInto<Ptr<QEvent>>) -> bool
pub unsafe fn event(&self, event: impl CastInto<Ptr<QEvent>>) -> bool
This virtual function receives events to an object and should return true if the event e was recognized and processed.
Calls C++ function: virtual bool QObject::event(QEvent* event)
.
This virtual function receives events to an object and should return true if the event e was recognized and processed.
The event() function can be reimplemented to customize the behavior of an object.
Make sure you call the parent event class implementation for all the events you did not handle.
Example:
class MyClass : public QWidget { Q_OBJECT
public: MyClass(QWidget *parent = 0); ~MyClass();
bool event(QEvent* ev) { if (ev->type() == QEvent::PolishRequest) { // overwrite handling of PolishRequest if any doThings(); return true; } else if (ev->type() == QEvent::Show) { // complement handling of Show if any doThings2(); QWidget::event(ev); return true; } // Make sure the rest of events are handled return QWidget::event(ev); } };
See also installEventFilter(), timerEvent(), QCoreApplication::sendEvent(), and QCoreApplication::postEvent().
Sourcepub unsafe fn event_filter(
&self,
watched: impl CastInto<Ptr<QObject>>,
event: impl CastInto<Ptr<QEvent>>,
) -> bool
pub unsafe fn event_filter( &self, watched: impl CastInto<Ptr<QObject>>, event: impl CastInto<Ptr<QEvent>>, ) -> bool
Filters events if this object has been installed as an event filter for the watched object.
Calls C++ function: virtual bool QObject::eventFilter(QObject* watched, QEvent* event)
.
Filters events if this object has been installed as an event filter for the watched object.
In your reimplementation of this function, if you want to filter the event out, i.e. stop it being handled further, return true; otherwise return false.
Example:
class MainWindow : public QMainWindow { public: MainWindow();
protected: bool eventFilter(QObject obj, QEvent ev);
private: QTextEdit *textEdit; };
MainWindow::MainWindow() { textEdit = new QTextEdit; setCentralWidget(textEdit);
textEdit->installEventFilter(this); }
bool MainWindow::eventFilter(QObject obj, QEvent event) { if (obj == textEdit) { if (event->type() == QEvent::KeyPress) { QKeyEvent keyEvent = static_cast<QKeyEvent>(event); qDebug() << “Ate key press” << keyEvent->key(); return true; } else { return false; } } else { // pass the event on to the parent class return QMainWindow::eventFilter(obj, event); } }
Notice in the example above that unhandled events are passed to the base class's eventFilter() function, since the base class might have reimplemented eventFilter() for its own internal purposes.
Warning: If you delete the receiver object in this function, be sure to return true. Otherwise, Qt will forward the event to the deleted object and the program might crash.
See also installEventFilter().
Sourcepub unsafe fn find_child_q_object_2a(
&self,
a_name: impl CastInto<Ref<QString>>,
options: QFlags<FindChildOption>,
) -> QPtr<QObject>
pub unsafe fn find_child_q_object_2a( &self, a_name: impl CastInto<Ref<QString>>, options: QFlags<FindChildOption>, ) -> QPtr<QObject>
Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. Omitting the name argument causes all object names to be matched. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.
Calls C++ function: QObject* QObject::findChild<QObject*>(const QString& aName = …, QFlags<Qt::FindChildOption> options = …) const
.
Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. Omitting the name argument causes all object names to be matched. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.
If there is more than one child matching the search, the most direct ancestor is returned. If there are several direct ancestors, it is undefined which one will be returned. In that case, findChildren() should be used.
This example returns a child QPushButton
of parentWidget
named "button1"
, even if the button isn't a direct child of the parent:
QPushButton button = parentWidget->findChild<QPushButton >(“button1”);
This example returns a QListWidget
child of parentWidget
:
QListWidget list = parentWidget->findChild<QListWidget >();
This example returns a child QPushButton
of parentWidget
(its direct parent) named "button1"
:
QPushButton button = parentWidget->findChild<QPushButton >(“button1”, Qt::FindDirectChildrenOnly);
This example returns a QListWidget
child of parentWidget
, its direct parent:
QListWidget list = parentWidget->findChild<QListWidget >(QString(), Qt::FindDirectChildrenOnly);
See also findChildren().
Sourcepub unsafe fn find_child_q_object_1a(
&self,
a_name: impl CastInto<Ref<QString>>,
) -> QPtr<QObject>
pub unsafe fn find_child_q_object_1a( &self, a_name: impl CastInto<Ref<QString>>, ) -> QPtr<QObject>
Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. Omitting the name argument causes all object names to be matched. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.
Calls C++ function: QObject* QObject::findChild<QObject*>(const QString& aName = …) const
.
Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. Omitting the name argument causes all object names to be matched. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.
If there is more than one child matching the search, the most direct ancestor is returned. If there are several direct ancestors, it is undefined which one will be returned. In that case, findChildren() should be used.
This example returns a child QPushButton
of parentWidget
named "button1"
, even if the button isn't a direct child of the parent:
QPushButton button = parentWidget->findChild<QPushButton >(“button1”);
This example returns a QListWidget
child of parentWidget
:
QListWidget list = parentWidget->findChild<QListWidget >();
This example returns a child QPushButton
of parentWidget
(its direct parent) named "button1"
:
QPushButton button = parentWidget->findChild<QPushButton >(“button1”, Qt::FindDirectChildrenOnly);
This example returns a QListWidget
child of parentWidget
, its direct parent:
QListWidget list = parentWidget->findChild<QListWidget >(QString(), Qt::FindDirectChildrenOnly);
See also findChildren().
Sourcepub unsafe fn find_child_q_object_0a(&self) -> QPtr<QObject>
pub unsafe fn find_child_q_object_0a(&self) -> QPtr<QObject>
Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. Omitting the name argument causes all object names to be matched. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.
Calls C++ function: QObject* QObject::findChild<QObject*>() const
.
Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. Omitting the name argument causes all object names to be matched. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.
If there is more than one child matching the search, the most direct ancestor is returned. If there are several direct ancestors, it is undefined which one will be returned. In that case, findChildren() should be used.
This example returns a child QPushButton
of parentWidget
named "button1"
, even if the button isn't a direct child of the parent:
QPushButton button = parentWidget->findChild<QPushButton >(“button1”);
This example returns a QListWidget
child of parentWidget
:
QListWidget list = parentWidget->findChild<QListWidget >();
This example returns a child QPushButton
of parentWidget
(its direct parent) named "button1"
:
QPushButton button = parentWidget->findChild<QPushButton >(“button1”, Qt::FindDirectChildrenOnly);
This example returns a QListWidget
child of parentWidget
, its direct parent:
QListWidget list = parentWidget->findChild<QListWidget >(QString(), Qt::FindDirectChildrenOnly);
See also findChildren().
Sourcepub unsafe fn find_children_q_object_q_string_q_flags_find_child_option(
&self,
a_name: impl CastInto<Ref<QString>>,
options: QFlags<FindChildOption>,
) -> CppBox<QListOfQObject>
pub unsafe fn find_children_q_object_q_string_q_flags_find_child_option( &self, a_name: impl CastInto<Ref<QString>>, options: QFlags<FindChildOption>, ) -> CppBox<QListOfQObject>
Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. Omitting the name argument causes all object names to be matched. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.
Calls C++ function: QList<QObject*> QObject::findChildren<QObject*>(const QString& aName = …, QFlags<Qt::FindChildOption> options = …) const
.
Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. Omitting the name argument causes all object names to be matched. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.
The following example shows how to find a list of child QWidget
s of the specified parentWidget
named widgetname
:
QList<QWidget > widgets = parentWidget.findChildren<QWidget >(“widgetname”);
This example returns all QPushButton
s that are children of parentWidget
:
QList<QPushButton > allPButtons = parentWidget.findChildren<QPushButton >();
This example returns all QPushButton
s that are immediate children of parentWidget
:
QList<QPushButton > childButtons = parentWidget.findChildren<QPushButton >(QString(), Qt::FindDirectChildrenOnly);
See also findChild().
Sourcepub unsafe fn find_children_q_object_q_reg_exp_q_flags_find_child_option(
&self,
re: impl CastInto<Ref<QRegExp>>,
options: QFlags<FindChildOption>,
) -> CppBox<QListOfQObject>
pub unsafe fn find_children_q_object_q_reg_exp_q_flags_find_child_option( &self, re: impl CastInto<Ref<QRegExp>>, options: QFlags<FindChildOption>, ) -> CppBox<QListOfQObject>
This function overloads findChildren().
Calls C++ function: QList<QObject*> QObject::findChildren<QObject*>(const QRegExp& re, QFlags<Qt::FindChildOption> options = …) const
.
This function overloads findChildren().
Returns the children of this object that can be cast to type T and that have names matching the regular expression regExp, or an empty list if there are no such objects. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.
Sourcepub unsafe fn find_children_q_object_q_regular_expression_q_flags_find_child_option(
&self,
re: impl CastInto<Ref<QRegularExpression>>,
options: QFlags<FindChildOption>,
) -> CppBox<QListOfQObject>
pub unsafe fn find_children_q_object_q_regular_expression_q_flags_find_child_option( &self, re: impl CastInto<Ref<QRegularExpression>>, options: QFlags<FindChildOption>, ) -> CppBox<QListOfQObject>
This function overloads findChildren().
Calls C++ function: QList<QObject*> QObject::findChildren<QObject*>(const QRegularExpression& re, QFlags<Qt::FindChildOption> options = …) const
.
This function overloads findChildren().
Returns the children of this object that can be cast to type T and that have names matching the regular expression re, or an empty list if there are no such objects. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.
This function was introduced in Qt 5.0.
Sourcepub unsafe fn find_children_q_object_q_string(
&self,
a_name: impl CastInto<Ref<QString>>,
) -> CppBox<QListOfQObject>
pub unsafe fn find_children_q_object_q_string( &self, a_name: impl CastInto<Ref<QString>>, ) -> CppBox<QListOfQObject>
Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. Omitting the name argument causes all object names to be matched. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.
Calls C++ function: QList<QObject*> QObject::findChildren<QObject*>(const QString& aName = …) const
.
Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. Omitting the name argument causes all object names to be matched. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.
The following example shows how to find a list of child QWidget
s of the specified parentWidget
named widgetname
:
QList<QWidget > widgets = parentWidget.findChildren<QWidget >(“widgetname”);
This example returns all QPushButton
s that are children of parentWidget
:
QList<QPushButton > allPButtons = parentWidget.findChildren<QPushButton >();
This example returns all QPushButton
s that are immediate children of parentWidget
:
QList<QPushButton > childButtons = parentWidget.findChildren<QPushButton >(QString(), Qt::FindDirectChildrenOnly);
See also findChild().
Sourcepub unsafe fn find_children_q_object(&self) -> CppBox<QListOfQObject>
pub unsafe fn find_children_q_object(&self) -> CppBox<QListOfQObject>
Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. Omitting the name argument causes all object names to be matched. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.
Calls C++ function: QList<QObject*> QObject::findChildren<QObject*>() const
.
Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. Omitting the name argument causes all object names to be matched. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.
The following example shows how to find a list of child QWidget
s of the specified parentWidget
named widgetname
:
QList<QWidget > widgets = parentWidget.findChildren<QWidget >(“widgetname”);
This example returns all QPushButton
s that are children of parentWidget
:
QList<QPushButton > allPButtons = parentWidget.findChildren<QPushButton >();
This example returns all QPushButton
s that are immediate children of parentWidget
:
QList<QPushButton > childButtons = parentWidget.findChildren<QPushButton >(QString(), Qt::FindDirectChildrenOnly);
See also findChild().
Sourcepub unsafe fn find_children_q_object_q_reg_exp(
&self,
re: impl CastInto<Ref<QRegExp>>,
) -> CppBox<QListOfQObject>
pub unsafe fn find_children_q_object_q_reg_exp( &self, re: impl CastInto<Ref<QRegExp>>, ) -> CppBox<QListOfQObject>
This function overloads findChildren().
Calls C++ function: QList<QObject*> QObject::findChildren<QObject*>(const QRegExp& re) const
.
This function overloads findChildren().
Returns the children of this object that can be cast to type T and that have names matching the regular expression regExp, or an empty list if there are no such objects. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.
Sourcepub unsafe fn find_children_q_object_q_regular_expression(
&self,
re: impl CastInto<Ref<QRegularExpression>>,
) -> CppBox<QListOfQObject>
pub unsafe fn find_children_q_object_q_regular_expression( &self, re: impl CastInto<Ref<QRegularExpression>>, ) -> CppBox<QListOfQObject>
This function overloads findChildren().
Calls C++ function: QList<QObject*> QObject::findChildren<QObject*>(const QRegularExpression& re) const
.
This function overloads findChildren().
Returns the children of this object that can be cast to type T and that have names matching the regular expression re, or an empty list if there are no such objects. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.
This function was introduced in Qt 5.0.
Sourcepub unsafe fn inherits(&self, classname: *const i8) -> bool
pub unsafe fn inherits(&self, classname: *const i8) -> bool
Returns true
if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false
.
Calls C++ function: bool QObject::inherits(const char* classname) const
.
Returns true
if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false
.
A class is considered to inherit itself.
Example:
QTimer *timer = new QTimer; // QTimer inherits QObject timer->inherits(“QTimer”); // returns true timer->inherits(“QObject”); // returns true timer->inherits(“QAbstractButton”); // returns false
// QVBoxLayout inherits QObject and QLayoutItem QVBoxLayout *layout = new QVBoxLayout; layout->inherits(“QObject”); // returns true layout->inherits(“QLayoutItem”); // returns true (even though QLayoutItem is not a QObject)
If you need to determine whether an object is an instance of a particular class for the purpose of casting it, consider using qobject_cast<Type *>(object) instead.
See also metaObject() and qobject_cast().
Sourcepub unsafe fn install_event_filter(
&self,
filter_obj: impl CastInto<Ptr<QObject>>,
)
pub unsafe fn install_event_filter( &self, filter_obj: impl CastInto<Ptr<QObject>>, )
Installs an event filter filterObj on this object. For example:
Calls C++ function: void QObject::installEventFilter(QObject* filterObj)
.
Installs an event filter filterObj on this object. For example:
monitoredObj->installEventFilter(filterObj);
An event filter is an object that receives all events that are sent to this object. The filter can either stop the event or forward it to this object. The event filter filterObj receives events via its eventFilter() function. The eventFilter() function must return true if the event should be filtered, (i.e. stopped); otherwise it must return false.
If multiple event filters are installed on a single object, the filter that was installed last is activated first.
Here's a KeyPressEater
class that eats the key presses of its monitored objects:
class KeyPressEater : public QObject { Q_OBJECT ...
protected: bool eventFilter(QObject obj, QEvent event); };
bool KeyPressEater::eventFilter(QObject obj, QEvent event) { if (event->type() == QEvent::KeyPress) { QKeyEvent keyEvent = static_cast<QKeyEvent >(event); qDebug(“Ate key press %d”, keyEvent->key()); return true; } else { // standard event processing return QObject::eventFilter(obj, event); } }
And here's how to install it on two widgets:
KeyPressEater keyPressEater = new KeyPressEater(this); QPushButton pushButton = new QPushButton(this); QListView *listView = new QListView(this);
pushButton->installEventFilter(keyPressEater); listView->installEventFilter(keyPressEater);
The QShortcut class, for example, uses this technique to intercept shortcut key presses.
Warning: If you delete the receiver object in your eventFilter() function, be sure to return true. If you return false, Qt sends the event to the deleted object and the program will crash.
Note that the filtering object must be in the same thread as this object. If filterObj is in a different thread, this function does nothing. If either filterObj or this object are moved to a different thread after calling this function, the event filter will not be called until both objects have the same thread affinity again (it is not removed).
See also removeEventFilter(), eventFilter(), and event().
Sourcepub unsafe fn is_widget_type(&self) -> bool
pub unsafe fn is_widget_type(&self) -> bool
Returns true
if the object is a widget; otherwise returns false
.
Calls C++ function: bool QObject::isWidgetType() const
.
Returns true
if the object is a widget; otherwise returns false
.
Calling this function is equivalent to calling inherits("QWidget")
, except that it is much faster.
Sourcepub unsafe fn is_window_type(&self) -> bool
pub unsafe fn is_window_type(&self) -> bool
Returns true
if the object is a window; otherwise returns false
.
Calls C++ function: bool QObject::isWindowType() const
.
Returns true
if the object is a window; otherwise returns false
.
Calling this function is equivalent to calling inherits("QWindow")
, except that it is much faster.
Sourcepub unsafe fn kill_timer(&self, id: i32)
pub unsafe fn kill_timer(&self, id: i32)
Kills the timer with timer identifier, id.
Calls C++ function: void QObject::killTimer(int id)
.
Kills the timer with timer identifier, id.
The timer identifier is returned by startTimer() when a timer event is started.
See also timerEvent() and startTimer().
Sourcepub unsafe fn meta_object(&self) -> Ptr<QMetaObject>
pub unsafe fn meta_object(&self) -> Ptr<QMetaObject>
Returns a pointer to the meta-object of this object.
Calls C++ function: virtual const QMetaObject* QObject::metaObject() const
.
Returns a pointer to the meta-object of this object.
A meta-object contains information about a class that inherits QObject, e.g. class name, superclass name, properties, signals and slots. Every QObject subclass that contains the Q_OBJECT macro will have a meta-object.
The meta-object information is required by the signal/slot connection mechanism and the property system. The inherits() function also makes use of the meta-object.
If you have no pointer to an actual object instance but still want to access the meta-object of a class, you can use staticMetaObject.
Example:
QObject *obj = new QPushButton; obj->metaObject()->className(); // returns “QPushButton”
QPushButton::staticMetaObject.className(); // returns “QPushButton”
See also staticMetaObject.
Sourcepub unsafe fn move_to_thread(&self, thread: impl CastInto<Ptr<QThread>>)
pub unsafe fn move_to_thread(&self, thread: impl CastInto<Ptr<QThread>>)
Changes the thread affinity for this object and its children. The object cannot be moved if it has a parent. Event processing will continue in the targetThread.
Calls C++ function: void QObject::moveToThread(QThread* thread)
.
Changes the thread affinity for this object and its children. The object cannot be moved if it has a parent. Event processing will continue in the targetThread.
To move an object to the main thread, use QApplication::instance() to retrieve a pointer to the current application, and then use QApplication::thread() to retrieve the thread in which the application lives. For example:
myObject->moveToThread(QApplication::instance()->thread());
If targetThread is zero, all event processing for this object and its children stops.
Note that all active timers for the object will be reset. The timers are first stopped in the current thread and restarted (with the same interval) in the targetThread. As a result, constantly moving an object between threads can postpone timer events indefinitely.
A QEvent::ThreadChange event is sent to this object just before the thread affinity is changed. You can handle this event to perform any special processing. Note that any new events that are posted to this object will be handled in the targetThread.
Warning: This function is not thread-safe; the current thread must be same as the current thread affinity. In other words, this function can only "push" an object from the current thread to another thread, it cannot "pull" an object from any arbitrary thread to the current thread.
See also thread().
Sourcepub unsafe fn object_name(&self) -> CppBox<QString>
pub unsafe fn object_name(&self) -> CppBox<QString>
This property holds the name of this object
Calls C++ function: QString QObject::objectName() const
.
This property holds the name of this object
You can find an object by name (and type) using findChild(). You can find a set of objects with findChildren().
qDebug(“MyClass::setPrecision(): (%s) invalid precision %f”, qPrintable(objectName()), newPrecision);
By default, this property contains an empty string.
Access functions:
QString | objectName() const |
void | setObjectName(const QString &name) |
Notifier signal:
void | objectNameChanged(const QString &objectName) | [see note below] |
Note: This is a private signal. It can be used in signal connections but cannot be emitted by the user.
See also metaObject() and QMetaObject::className().
Sourcepub unsafe fn parent(&self) -> QPtr<QObject>
pub unsafe fn parent(&self) -> QPtr<QObject>
Returns a pointer to the parent object.
Calls C++ function: QObject* QObject::parent() const
.
Sourcepub unsafe fn property(&self, name: *const i8) -> CppBox<QVariant>
pub unsafe fn property(&self, name: *const i8) -> CppBox<QVariant>
Returns the value of the object's name property.
Calls C++ function: QVariant QObject::property(const char* name) const
.
Returns the value of the object’s name property.
If no such property exists, the returned variant is invalid.
Information about all available properties is provided through the metaObject() and dynamicPropertyNames().
See also setProperty(), QVariant::isValid(), metaObject(), and dynamicPropertyNames().
Sourcepub unsafe fn qt_metacall(
&self,
arg1: Call,
arg2: i32,
arg3: *mut *mut c_void,
) -> i32
pub unsafe fn qt_metacall( &self, arg1: Call, arg2: i32, arg3: *mut *mut c_void, ) -> i32
Calls C++ function: virtual int QObject::qt_metacall(QMetaObject::Call arg1, int arg2, void** arg3)
.
Sourcepub unsafe fn qt_metacast(&self, arg1: *const i8) -> *mut c_void
pub unsafe fn qt_metacast(&self, arg1: *const i8) -> *mut c_void
Calls C++ function: virtual void* QObject::qt_metacast(const char* arg1)
.
Sourcepub unsafe fn remove_event_filter(&self, obj: impl CastInto<Ptr<QObject>>)
pub unsafe fn remove_event_filter(&self, obj: impl CastInto<Ptr<QObject>>)
Removes an event filter object obj from this object. The request is ignored if such an event filter has not been installed.
Calls C++ function: void QObject::removeEventFilter(QObject* obj)
.
Removes an event filter object obj from this object. The request is ignored if such an event filter has not been installed.
All event filters for this object are automatically removed when this object is destroyed.
It is always safe to remove an event filter, even during event filter activation (i.e. from the eventFilter() function).
See also installEventFilter(), eventFilter(), and event().
Sourcepub unsafe fn set_object_name(&self, name: impl CastInto<Ref<QString>>)
pub unsafe fn set_object_name(&self, name: impl CastInto<Ref<QString>>)
This property holds the name of this object
Calls C++ function: void QObject::setObjectName(const QString& name)
.
This property holds the name of this object
You can find an object by name (and type) using findChild(). You can find a set of objects with findChildren().
qDebug(“MyClass::setPrecision(): (%s) invalid precision %f”, qPrintable(objectName()), newPrecision);
By default, this property contains an empty string.
Access functions:
QString | objectName() const |
void | setObjectName(const QString &name) |
Notifier signal:
void | objectNameChanged(const QString &objectName) | [see note below] |
Note: This is a private signal. It can be used in signal connections but cannot be emitted by the user.
See also metaObject() and QMetaObject::className().
Sourcepub unsafe fn set_parent(&self, parent: impl CastInto<Ptr<QObject>>)
pub unsafe fn set_parent(&self, parent: impl CastInto<Ptr<QObject>>)
Makes the object a child of parent.
Calls C++ function: void QObject::setParent(QObject* parent)
.
Sourcepub unsafe fn set_property(
&self,
name: *const i8,
value: impl CastInto<Ref<QVariant>>,
) -> bool
pub unsafe fn set_property( &self, name: *const i8, value: impl CastInto<Ref<QVariant>>, ) -> bool
Sets the value of the object's name property to value.
Calls C++ function: bool QObject::setProperty(const char* name, const QVariant& value)
.
Sets the value of the object’s name property to value.
If the property is defined in the class using Q_PROPERTY then true is returned on success and false otherwise. If the property is not defined using Q_PROPERTY, and therefore not listed in the meta-object, it is added as a dynamic property and false is returned.
Information about all available properties is provided through the metaObject() and dynamicPropertyNames().
Dynamic properties can be queried again using property() and can be removed by setting the property value to an invalid QVariant. Changing the value of a dynamic property causes a QDynamicPropertyChangeEvent to be sent to the object.
Note: Dynamic properties starting with "_q_" are reserved for internal purposes.
See also property(), metaObject(), dynamicPropertyNames(), and QMetaProperty::write().
Sourcepub unsafe fn signals_blocked(&self) -> bool
pub unsafe fn signals_blocked(&self) -> bool
Returns true
if signals are blocked; otherwise returns false
.
Calls C++ function: bool QObject::signalsBlocked() const
.
Returns true
if signals are blocked; otherwise returns false
.
Signals are not blocked by default.
See also blockSignals() and QSignalBlocker.
Sourcepub unsafe fn start_timer_2a(&self, interval: i32, timer_type: TimerType) -> i32
pub unsafe fn start_timer_2a(&self, interval: i32, timer_type: TimerType) -> i32
Starts a timer and returns a timer identifier, or returns zero if it could not start a timer.
Calls C++ function: int QObject::startTimer(int interval, Qt::TimerType timerType = …)
.
Starts a timer and returns a timer identifier, or returns zero if it could not start a timer.
A timer event will occur every interval milliseconds until killTimer() is called. If interval is 0, then the timer event occurs once every time there are no more window system events to process.
The virtual timerEvent() function is called with the QTimerEvent event parameter class when a timer event occurs. Reimplement this function to get timer events.
If multiple timers are running, the QTimerEvent::timerId() can be used to find out which timer was activated.
Example:
class MyObject : public QObject { Q_OBJECT
public: MyObject(QObject *parent = 0);
protected: void timerEvent(QTimerEvent *event); };
MyObject::MyObject(QObject *parent) : QObject(parent) { startTimer(50); // 50-millisecond timer startTimer(1000); // 1-second timer startTimer(60000); // 1-minute timer
using namespace std::chrono; startTimer(milliseconds(50)); startTimer(seconds(1)); startTimer(minutes(1));
// since C++14 we can use std::chrono::duration literals, e.g.: startTimer(100ms); startTimer(5s); startTimer(2min); startTimer(1h); }
void MyObject::timerEvent(QTimerEvent *event) { qDebug() << “Timer ID:” << event->timerId(); }
Note that QTimer's accuracy depends on the underlying operating system and hardware. The timerType argument allows you to customize the accuracy of the timer. See Qt::TimerType for information on the different timer types. Most platforms support an accuracy of 20 milliseconds; some provide more. If Qt is unable to deliver the requested number of timer events, it will silently discard some.
The QTimer class provides a high-level programming interface with single-shot timers and timer signals instead of events. There is also a QBasicTimer class that is more lightweight than QTimer and less clumsy than using timer IDs directly.
See also timerEvent(), killTimer(), and QTimer::singleShot().
Sourcepub unsafe fn start_timer_1a(&self, interval: i32) -> i32
pub unsafe fn start_timer_1a(&self, interval: i32) -> i32
Starts a timer and returns a timer identifier, or returns zero if it could not start a timer.
Calls C++ function: int QObject::startTimer(int interval)
.
Starts a timer and returns a timer identifier, or returns zero if it could not start a timer.
A timer event will occur every interval milliseconds until killTimer() is called. If interval is 0, then the timer event occurs once every time there are no more window system events to process.
The virtual timerEvent() function is called with the QTimerEvent event parameter class when a timer event occurs. Reimplement this function to get timer events.
If multiple timers are running, the QTimerEvent::timerId() can be used to find out which timer was activated.
Example:
class MyObject : public QObject { Q_OBJECT
public: MyObject(QObject *parent = 0);
protected: void timerEvent(QTimerEvent *event); };
MyObject::MyObject(QObject *parent) : QObject(parent) { startTimer(50); // 50-millisecond timer startTimer(1000); // 1-second timer startTimer(60000); // 1-minute timer
using namespace std::chrono; startTimer(milliseconds(50)); startTimer(seconds(1)); startTimer(minutes(1));
// since C++14 we can use std::chrono::duration literals, e.g.: startTimer(100ms); startTimer(5s); startTimer(2min); startTimer(1h); }
void MyObject::timerEvent(QTimerEvent *event) { qDebug() << “Timer ID:” << event->timerId(); }
Note that QTimer's accuracy depends on the underlying operating system and hardware. The timerType argument allows you to customize the accuracy of the timer. See Qt::TimerType for information on the different timer types. Most platforms support an accuracy of 20 milliseconds; some provide more. If Qt is unable to deliver the requested number of timer events, it will silently discard some.
The QTimer class provides a high-level programming interface with single-shot timers and timer signals instead of events. There is also a QBasicTimer class that is more lightweight than QTimer and less clumsy than using timer IDs directly.
See also timerEvent(), killTimer(), and QTimer::singleShot().
Sourcepub unsafe fn thread(&self) -> QPtr<QThread>
pub unsafe fn thread(&self) -> QPtr<QThread>
Returns the thread in which the object lives.
Calls C++ function: QThread* QObject::thread() const
.
Returns the thread in which the object lives.
See also moveToThread().
Trait Implementations§
Source§impl CppDeletable for QGraphicsProxyWidget
impl CppDeletable for QGraphicsProxyWidget
Source§impl Deref for QGraphicsProxyWidget
impl Deref for QGraphicsProxyWidget
Source§fn deref(&self) -> &QGraphicsWidget
fn deref(&self) -> &QGraphicsWidget
Calls C++ function: QGraphicsWidget* static_cast<QGraphicsWidget*>(QGraphicsProxyWidget* ptr)
.
Source§type Target = QGraphicsWidget
type Target = QGraphicsWidget
Source§impl DynamicCast<QGraphicsProxyWidget> for QGraphicsItem
impl DynamicCast<QGraphicsProxyWidget> for QGraphicsItem
Source§unsafe fn dynamic_cast(ptr: Ptr<QGraphicsItem>) -> Ptr<QGraphicsProxyWidget>
unsafe fn dynamic_cast(ptr: Ptr<QGraphicsItem>) -> Ptr<QGraphicsProxyWidget>
Calls C++ function: QGraphicsProxyWidget* dynamic_cast<QGraphicsProxyWidget*>(QGraphicsItem* ptr)
.
Source§impl DynamicCast<QGraphicsProxyWidget> for QGraphicsLayoutItem
impl DynamicCast<QGraphicsProxyWidget> for QGraphicsLayoutItem
Source§unsafe fn dynamic_cast(
ptr: Ptr<QGraphicsLayoutItem>,
) -> Ptr<QGraphicsProxyWidget>
unsafe fn dynamic_cast( ptr: Ptr<QGraphicsLayoutItem>, ) -> Ptr<QGraphicsProxyWidget>
Calls C++ function: QGraphicsProxyWidget* dynamic_cast<QGraphicsProxyWidget*>(QGraphicsLayoutItem* ptr)
.
Source§impl DynamicCast<QGraphicsProxyWidget> for QGraphicsObject
impl DynamicCast<QGraphicsProxyWidget> for QGraphicsObject
Source§unsafe fn dynamic_cast(ptr: Ptr<QGraphicsObject>) -> Ptr<QGraphicsProxyWidget>
unsafe fn dynamic_cast(ptr: Ptr<QGraphicsObject>) -> Ptr<QGraphicsProxyWidget>
Calls C++ function: QGraphicsProxyWidget* dynamic_cast<QGraphicsProxyWidget*>(QGraphicsObject* ptr)
.
Source§impl DynamicCast<QGraphicsProxyWidget> for QGraphicsWidget
impl DynamicCast<QGraphicsProxyWidget> for QGraphicsWidget
Source§unsafe fn dynamic_cast(ptr: Ptr<QGraphicsWidget>) -> Ptr<QGraphicsProxyWidget>
unsafe fn dynamic_cast(ptr: Ptr<QGraphicsWidget>) -> Ptr<QGraphicsProxyWidget>
Calls C++ function: QGraphicsProxyWidget* dynamic_cast<QGraphicsProxyWidget*>(QGraphicsWidget* ptr)
.
Source§impl DynamicCast<QGraphicsProxyWidget> for QObject
impl DynamicCast<QGraphicsProxyWidget> for QObject
Source§unsafe fn dynamic_cast(ptr: Ptr<QObject>) -> Ptr<QGraphicsProxyWidget>
unsafe fn dynamic_cast(ptr: Ptr<QObject>) -> Ptr<QGraphicsProxyWidget>
Calls C++ function: QGraphicsProxyWidget* dynamic_cast<QGraphicsProxyWidget*>(QObject* ptr)
.
Source§impl StaticDowncast<QGraphicsProxyWidget> for QGraphicsItem
impl StaticDowncast<QGraphicsProxyWidget> for QGraphicsItem
Source§unsafe fn static_downcast(ptr: Ptr<QGraphicsItem>) -> Ptr<QGraphicsProxyWidget>
unsafe fn static_downcast(ptr: Ptr<QGraphicsItem>) -> Ptr<QGraphicsProxyWidget>
Calls C++ function: QGraphicsProxyWidget* static_cast<QGraphicsProxyWidget*>(QGraphicsItem* ptr)
.
Source§impl StaticDowncast<QGraphicsProxyWidget> for QGraphicsLayoutItem
impl StaticDowncast<QGraphicsProxyWidget> for QGraphicsLayoutItem
Source§unsafe fn static_downcast(
ptr: Ptr<QGraphicsLayoutItem>,
) -> Ptr<QGraphicsProxyWidget>
unsafe fn static_downcast( ptr: Ptr<QGraphicsLayoutItem>, ) -> Ptr<QGraphicsProxyWidget>
Calls C++ function: QGraphicsProxyWidget* static_cast<QGraphicsProxyWidget*>(QGraphicsLayoutItem* ptr)
.
Source§impl StaticDowncast<QGraphicsProxyWidget> for QGraphicsObject
impl StaticDowncast<QGraphicsProxyWidget> for QGraphicsObject
Source§unsafe fn static_downcast(
ptr: Ptr<QGraphicsObject>,
) -> Ptr<QGraphicsProxyWidget>
unsafe fn static_downcast( ptr: Ptr<QGraphicsObject>, ) -> Ptr<QGraphicsProxyWidget>
Calls C++ function: QGraphicsProxyWidget* static_cast<QGraphicsProxyWidget*>(QGraphicsObject* ptr)
.
Source§impl StaticDowncast<QGraphicsProxyWidget> for QGraphicsWidget
impl StaticDowncast<QGraphicsProxyWidget> for QGraphicsWidget
Source§unsafe fn static_downcast(
ptr: Ptr<QGraphicsWidget>,
) -> Ptr<QGraphicsProxyWidget>
unsafe fn static_downcast( ptr: Ptr<QGraphicsWidget>, ) -> Ptr<QGraphicsProxyWidget>
Calls C++ function: QGraphicsProxyWidget* static_cast<QGraphicsProxyWidget*>(QGraphicsWidget* ptr)
.
Source§impl StaticDowncast<QGraphicsProxyWidget> for QObject
impl StaticDowncast<QGraphicsProxyWidget> for QObject
Source§unsafe fn static_downcast(ptr: Ptr<QObject>) -> Ptr<QGraphicsProxyWidget>
unsafe fn static_downcast(ptr: Ptr<QObject>) -> Ptr<QGraphicsProxyWidget>
Calls C++ function: QGraphicsProxyWidget* static_cast<QGraphicsProxyWidget*>(QObject* ptr)
.
Source§impl StaticUpcast<QGraphicsItem> for QGraphicsProxyWidget
impl StaticUpcast<QGraphicsItem> for QGraphicsProxyWidget
Source§unsafe fn static_upcast(ptr: Ptr<QGraphicsProxyWidget>) -> Ptr<QGraphicsItem>
unsafe fn static_upcast(ptr: Ptr<QGraphicsProxyWidget>) -> Ptr<QGraphicsItem>
Calls C++ function: QGraphicsItem* static_cast<QGraphicsItem*>(QGraphicsProxyWidget* ptr)
.
Source§impl StaticUpcast<QGraphicsLayoutItem> for QGraphicsProxyWidget
impl StaticUpcast<QGraphicsLayoutItem> for QGraphicsProxyWidget
Source§unsafe fn static_upcast(
ptr: Ptr<QGraphicsProxyWidget>,
) -> Ptr<QGraphicsLayoutItem>
unsafe fn static_upcast( ptr: Ptr<QGraphicsProxyWidget>, ) -> Ptr<QGraphicsLayoutItem>
Calls C++ function: QGraphicsLayoutItem* static_cast<QGraphicsLayoutItem*>(QGraphicsProxyWidget* ptr)
.
Source§impl StaticUpcast<QGraphicsObject> for QGraphicsProxyWidget
impl StaticUpcast<QGraphicsObject> for QGraphicsProxyWidget
Source§unsafe fn static_upcast(ptr: Ptr<QGraphicsProxyWidget>) -> Ptr<QGraphicsObject>
unsafe fn static_upcast(ptr: Ptr<QGraphicsProxyWidget>) -> Ptr<QGraphicsObject>
Calls C++ function: QGraphicsObject* static_cast<QGraphicsObject*>(QGraphicsProxyWidget* ptr)
.
Source§impl StaticUpcast<QGraphicsWidget> for QGraphicsProxyWidget
impl StaticUpcast<QGraphicsWidget> for QGraphicsProxyWidget
Source§unsafe fn static_upcast(ptr: Ptr<QGraphicsProxyWidget>) -> Ptr<QGraphicsWidget>
unsafe fn static_upcast(ptr: Ptr<QGraphicsProxyWidget>) -> Ptr<QGraphicsWidget>
Calls C++ function: QGraphicsWidget* static_cast<QGraphicsWidget*>(QGraphicsProxyWidget* ptr)
.
Source§impl StaticUpcast<QObject> for QGraphicsProxyWidget
impl StaticUpcast<QObject> for QGraphicsProxyWidget
Source§unsafe fn static_upcast(ptr: Ptr<QGraphicsProxyWidget>) -> Ptr<QObject>
unsafe fn static_upcast(ptr: Ptr<QGraphicsProxyWidget>) -> Ptr<QObject>
Calls C++ function: QObject* static_cast<QObject*>(QGraphicsProxyWidget* ptr)
.