[][src]Struct qt_widgets::QStackedWidget

#[repr(C)]pub struct QStackedWidget { /* fields omitted */ }

The QStackedWidget class provides a stack of widgets where only one widget is visible at a time.

C++ class: QStackedWidget.

C++ documentation:

The QStackedWidget class provides a stack of widgets where only one widget is visible at a time.

QStackedWidget can be used to create a user interface similar to the one provided by QTabWidget. It is a convenience layout widget built on top of the QStackedLayout class.

Like QStackedLayout, QStackedWidget can be constructed and populated with a number of child widgets ("pages"):

QWidget firstPageWidget = new QWidget; QWidget secondPageWidget = new QWidget; QWidget *thirdPageWidget = new QWidget;

QStackedWidget *stackedWidget = new QStackedWidget; stackedWidget->addWidget(firstPageWidget); stackedWidget->addWidget(secondPageWidget); stackedWidget->addWidget(thirdPageWidget);

QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(stackedWidget); setLayout(layout);

QStackedWidget provides no intrinsic means for the user to switch page. This is typically done through a QComboBox or a QListWidget that stores the titles of the QStackedWidget's pages. For example:

QComboBox *pageComboBox = new QComboBox; pageComboBox->addItem(tr("Page 1")); pageComboBox->addItem(tr("Page 2")); pageComboBox->addItem(tr("Page 3")); connect(pageComboBox, SIGNAL(activated(int)), stackedWidget, SLOT(setCurrentIndex(int)));

When populating a stacked widget, the widgets are added to an internal list. The indexOf() function returns the index of a widget in that list. The widgets can either be added to the end of the list using the addWidget() function, or inserted at a given index using the insertWidget() function. The removeWidget() function removes a widget from the stacked widget. The number of widgets contained in the stacked widget can be obtained using the count() function.

The widget() function returns the widget at a given index position. The index of the widget that is shown on screen is given by currentIndex() and can be changed using setCurrentIndex(). In a similar manner, the currently shown widget can be retrieved using the currentWidget() function, and altered using the setCurrentWidget() function.

Whenever the current widget in the stacked widget changes or a widget is removed from the stacked widget, the currentChanged() and widgetRemoved() signals are emitted respectively.

Methods

impl QStackedWidget[src]

pub fn slot_set_current_index(&self) -> Receiver<(c_int,)>[src]

This property holds the index position of the widget that is visible

Returns a built-in Qt slot QStackedWidget::setCurrentIndex that can be passed to qt_core::Signal::connect.

C++ documentation:

This property holds the index position of the widget that is visible

The current index is -1 if there is no current widget.

By default, this property contains a value of -1 because the stack is initially empty.

Access functions:

int currentIndex() const
void setCurrentIndex(int index)

Notifier signal:

void currentChanged(int index)

See also currentWidget() and indexOf().

pub fn slot_set_current_widget(&self) -> Receiver<(*mut QWidget,)>[src]

Sets the current widget to be the specified widget. The new current widget must already be contained in this stacked widget.

Returns a built-in Qt slot QStackedWidget::setCurrentWidget that can be passed to qt_core::Signal::connect.

C++ documentation:

Sets the current widget to be the specified widget. The new current widget must already be contained in this stacked widget.

See also currentWidget() and setCurrentIndex().

pub fn current_changed(&self) -> Signal<(c_int,)>[src]

This signal is emitted whenever the current widget changes.

Returns a built-in Qt signal QStackedWidget::currentChanged that can be passed to qt_core::Signal::connect.

C++ documentation:

This signal is emitted whenever the current widget changes.

The parameter holds the index of the new current widget, or -1 if there isn't a new one (for example, if there are no widgets in the QStackedWidget).

Note: Notifier signal for property currentIndex.

See also currentWidget() and setCurrentWidget().

pub fn widget_removed(&self) -> Signal<(c_int,)>[src]

This signal is emitted whenever a widget is removed. The widget's index is passed as parameter.

Returns a built-in Qt signal QStackedWidget::widgetRemoved that can be passed to qt_core::Signal::connect.

C++ documentation:

This signal is emitted whenever a widget is removed. The widget's index is passed as parameter.

See also removeWidget().

pub unsafe fn add_widget(&self, w: impl CastInto<Ptr<QWidget>>) -> c_int[src]

Appends the given widget to the QStackedWidget and returns the index position. Ownership of widget is passed on to the QStackedWidget.

Calls C++ function: int QStackedWidget::addWidget(QWidget* w).

C++ documentation:

Appends the given widget to the QStackedWidget and returns the index position. Ownership of widget is passed on to the QStackedWidget.

If the QStackedWidget is empty before this function is called, widget becomes the current widget.

See also insertWidget(), removeWidget(), and setCurrentWidget().

pub unsafe fn count(&self) -> c_int[src]

This property holds the number of widgets contained by this stacked widget

Calls C++ function: int QStackedWidget::count() const.

C++ documentation:

This property holds the number of widgets contained by this stacked widget

By default, this property contains a value of 0.

Access functions:

int count() const

See also currentIndex() and widget().

pub unsafe fn current_index(&self) -> c_int[src]

This property holds the index position of the widget that is visible

Calls C++ function: int QStackedWidget::currentIndex() const.

C++ documentation:

This property holds the index position of the widget that is visible

The current index is -1 if there is no current widget.

By default, this property contains a value of -1 because the stack is initially empty.

Access functions:

int currentIndex() const
void setCurrentIndex(int index)

Notifier signal:

void currentChanged(int index)

See also currentWidget() and indexOf().

pub unsafe fn current_widget(&self) -> QPtr<QWidget>[src]

Returns the current widget, or 0 if there are no child widgets.

Calls C++ function: QWidget* QStackedWidget::currentWidget() const.

C++ documentation:

Returns the current widget, or 0 if there are no child widgets.

See also currentIndex() and setCurrentWidget().

pub unsafe fn index_of(&self, arg1: impl CastInto<Ptr<QWidget>>) -> c_int[src]

Returns the index of the given widget, or -1 if the given widget is not a child of the QStackedWidget.

Calls C++ function: int QStackedWidget::indexOf(QWidget* arg1) const.

C++ documentation:

Returns the index of the given widget, or -1 if the given widget is not a child of the QStackedWidget.

See also currentIndex() and widget().

pub unsafe fn insert_widget(
    &self,
    index: c_int,
    w: impl CastInto<Ptr<QWidget>>
) -> c_int
[src]

Inserts the given widget at the given index in the QStackedWidget. Ownership of widget is passed on to the QStackedWidget. If index is out of range, the widget is appended (in which case it is the actual index of the widget that is returned).

Calls C++ function: int QStackedWidget::insertWidget(int index, QWidget* w).

C++ documentation:

Inserts the given widget at the given index in the QStackedWidget. Ownership of widget is passed on to the QStackedWidget. If index is out of range, the widget is appended (in which case it is the actual index of the widget that is returned).

If the QStackedWidget was empty before this function is called, the given widget becomes the current widget.

Inserting a new widget at an index less than or equal to the current index will increment the current index, but keep the current widget.

See also addWidget(), removeWidget(), and setCurrentWidget().

pub unsafe fn meta_object(&self) -> Ptr<QMetaObject>[src]

Calls C++ function: virtual const QMetaObject* QStackedWidget::metaObject() const.

pub unsafe fn new_1a(
    parent: impl CastInto<Ptr<QWidget>>
) -> QBox<QStackedWidget>
[src]

Constructs a QStackedWidget with the given parent.

Calls C++ function: [constructor] void QStackedWidget::QStackedWidget(QWidget* parent = …).

C++ documentation:

Constructs a QStackedWidget with the given parent.

See also addWidget() and insertWidget().

pub unsafe fn new_0a() -> QBox<QStackedWidget>[src]

The QStackedWidget class provides a stack of widgets where only one widget is visible at a time.

Calls C++ function: [constructor] void QStackedWidget::QStackedWidget().

C++ documentation:

The QStackedWidget class provides a stack of widgets where only one widget is visible at a time.

QStackedWidget can be used to create a user interface similar to the one provided by QTabWidget. It is a convenience layout widget built on top of the QStackedLayout class.

Like QStackedLayout, QStackedWidget can be constructed and populated with a number of child widgets ("pages"):

QWidget firstPageWidget = new QWidget; QWidget secondPageWidget = new QWidget; QWidget *thirdPageWidget = new QWidget;

QStackedWidget *stackedWidget = new QStackedWidget; stackedWidget->addWidget(firstPageWidget); stackedWidget->addWidget(secondPageWidget); stackedWidget->addWidget(thirdPageWidget);

QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(stackedWidget); setLayout(layout);

QStackedWidget provides no intrinsic means for the user to switch page. This is typically done through a QComboBox or a QListWidget that stores the titles of the QStackedWidget's pages. For example:

QComboBox *pageComboBox = new QComboBox; pageComboBox->addItem(tr("Page 1")); pageComboBox->addItem(tr("Page 2")); pageComboBox->addItem(tr("Page 3")); connect(pageComboBox, SIGNAL(activated(int)), stackedWidget, SLOT(setCurrentIndex(int)));

When populating a stacked widget, the widgets are added to an internal list. The indexOf() function returns the index of a widget in that list. The widgets can either be added to the end of the list using the addWidget() function, or inserted at a given index using the insertWidget() function. The removeWidget() function removes a widget from the stacked widget. The number of widgets contained in the stacked widget can be obtained using the count() function.

The widget() function returns the widget at a given index position. The index of the widget that is shown on screen is given by currentIndex() and can be changed using setCurrentIndex(). In a similar manner, the currently shown widget can be retrieved using the currentWidget() function, and altered using the setCurrentWidget() function.

Whenever the current widget in the stacked widget changes or a widget is removed from the stacked widget, the currentChanged() and widgetRemoved() signals are emitted respectively.

pub unsafe fn qt_metacall(
    &self,
    arg1: Call,
    arg2: c_int,
    arg3: *mut *mut c_void
) -> c_int
[src]

Calls C++ function: virtual int QStackedWidget::qt_metacall(QMetaObject::Call arg1, int arg2, void** arg3).

pub unsafe fn qt_metacast(&self, arg1: *const c_char) -> *mut c_void[src]

Calls C++ function: virtual void* QStackedWidget::qt_metacast(const char* arg1).

pub unsafe fn remove_widget(&self, w: impl CastInto<Ptr<QWidget>>)[src]

Removes widget from the QStackedWidget. i.e., widget is not deleted but simply removed from the stacked layout, causing it to be hidden.

Calls C++ function: void QStackedWidget::removeWidget(QWidget* w).

C++ documentation:

Removes widget from the QStackedWidget. i.e., widget is not deleted but simply removed from the stacked layout, causing it to be hidden.

Note: Parent object and parent widget of widget will remain the QStackedWidget. If the application wants to reuse the removed widget, then it is recommended to re-parent it.

See also addWidget(), insertWidget(), and currentWidget().

pub unsafe fn set_current_index(&self, index: c_int)[src]

This property holds the index position of the widget that is visible

Calls C++ function: [slot] void QStackedWidget::setCurrentIndex(int index).

C++ documentation:

This property holds the index position of the widget that is visible

The current index is -1 if there is no current widget.

By default, this property contains a value of -1 because the stack is initially empty.

Access functions:

int currentIndex() const
void setCurrentIndex(int index)

Notifier signal:

void currentChanged(int index)

See also currentWidget() and indexOf().

pub unsafe fn set_current_widget(&self, w: impl CastInto<Ptr<QWidget>>)[src]

Sets the current widget to be the specified widget. The new current widget must already be contained in this stacked widget.

Calls C++ function: [slot] void QStackedWidget::setCurrentWidget(QWidget* w).

C++ documentation:

Sets the current widget to be the specified widget. The new current widget must already be contained in this stacked widget.

See also currentWidget() and setCurrentIndex().

pub unsafe fn static_meta_object() -> Ref<QMetaObject>[src]

Returns a reference to the staticMetaObject field.

pub unsafe fn tr(
    s: *const c_char,
    c: *const c_char,
    n: c_int
) -> CppBox<QString>
[src]

Calls C++ function: static QString QStackedWidget::tr(const char* s, const char* c, int n).

pub unsafe fn tr_utf8(
    s: *const c_char,
    c: *const c_char,
    n: c_int
) -> CppBox<QString>
[src]

Calls C++ function: static QString QStackedWidget::trUtf8(const char* s, const char* c, int n).

pub unsafe fn widget(&self, arg1: c_int) -> QPtr<QWidget>[src]

Returns the widget at the given index, or 0 if there is no such widget.

Calls C++ function: QWidget* QStackedWidget::widget(int arg1) const.

C++ documentation:

Returns the widget at the given index, or 0 if there is no such widget.

See also currentWidget() and indexOf().

Methods from Deref<Target = QFrame>

pub unsafe fn frame_rect(&self) -> CppBox<QRect>[src]

This property holds the frame's rectangle

Calls C++ function: QRect QFrame::frameRect() const.

C++ documentation:

This property holds the frame's rectangle

The frame's rectangle is the rectangle the frame is drawn in. By default, this is the entire widget. Setting the rectangle does does not cause a widget update. The frame rectangle is automatically adjusted when the widget changes size.

If you set the rectangle to a null rectangle (for example, QRect(0, 0, 0, 0)), then the resulting frame rectangle is equivalent to the widget rectangle.

Access functions:

QRect frameRect() const
void setFrameRect(const QRect &)

pub unsafe fn frame_shadow(&self) -> Shadow[src]

This property holds the frame shadow value from the frame style

Calls C++ function: QFrame::Shadow QFrame::frameShadow() const.

C++ documentation:

This property holds the frame shadow value from the frame style

Access functions:

Shadow frameShadow() const
void setFrameShadow(Shadow)

See also frameStyle() and frameShape().

pub unsafe fn frame_shape(&self) -> Shape[src]

This property holds the frame shape value from the frame style

Calls C++ function: QFrame::Shape QFrame::frameShape() const.

C++ documentation:

This property holds the frame shape value from the frame style

Access functions:

Shape frameShape() const
void setFrameShape(Shape)

See also frameStyle() and frameShadow().

pub unsafe fn frame_style(&self) -> c_int[src]

Returns the frame style.

Calls C++ function: int QFrame::frameStyle() const.

C++ documentation:

Returns the frame style.

The default value is QFrame::Plain.

See also setFrameStyle(), frameShape(), and frameShadow().

pub unsafe fn frame_width(&self) -> c_int[src]

This property holds the width of the frame that is drawn.

Calls C++ function: int QFrame::frameWidth() const.

C++ documentation:

This property holds the width of the frame that is drawn.

Note that the frame width depends on the frame style, not only the line width and the mid-line width. For example, the style specified by NoFrame always has a frame width of 0, whereas the style Panel has a frame width equivalent to the line width.

Access functions:

int frameWidth() const

See also lineWidth(), midLineWidth(), and frameStyle().

pub unsafe fn line_width(&self) -> c_int[src]

This property holds the line width

Calls C++ function: int QFrame::lineWidth() const.

C++ documentation:

This property holds the line width

Note that the total line width for frames used as separators (HLine and VLine) is specified by frameWidth.

The default value is 1.

Access functions:

int lineWidth() const
void setLineWidth(int)

See also midLineWidth and frameWidth.

pub unsafe fn meta_object(&self) -> Ptr<QMetaObject>[src]

Calls C++ function: virtual const QMetaObject* QFrame::metaObject() const.

pub unsafe fn mid_line_width(&self) -> c_int[src]

This property holds the width of the mid-line

Calls C++ function: int QFrame::midLineWidth() const.

C++ documentation:

This property holds the width of the mid-line

The default value is 0.

Access functions:

int midLineWidth() const
void setMidLineWidth(int)

See also lineWidth and frameWidth.

pub unsafe fn qt_metacall(
    &self,
    arg1: Call,
    arg2: c_int,
    arg3: *mut *mut c_void
) -> c_int
[src]

Calls C++ function: virtual int QFrame::qt_metacall(QMetaObject::Call arg1, int arg2, void** arg3).

pub unsafe fn qt_metacast(&self, arg1: *const c_char) -> *mut c_void[src]

Calls C++ function: virtual void* QFrame::qt_metacast(const char* arg1).

pub unsafe fn set_frame_rect(&self, arg1: impl CastInto<Ref<QRect>>)[src]

This property holds the frame's rectangle

Calls C++ function: void QFrame::setFrameRect(const QRect& arg1).

C++ documentation:

This property holds the frame's rectangle

The frame's rectangle is the rectangle the frame is drawn in. By default, this is the entire widget. Setting the rectangle does does not cause a widget update. The frame rectangle is automatically adjusted when the widget changes size.

If you set the rectangle to a null rectangle (for example, QRect(0, 0, 0, 0)), then the resulting frame rectangle is equivalent to the widget rectangle.

Access functions:

QRect frameRect() const
void setFrameRect(const QRect &)

pub unsafe fn set_frame_shadow(&self, arg1: Shadow)[src]

This property holds the frame shadow value from the frame style

Calls C++ function: void QFrame::setFrameShadow(QFrame::Shadow arg1).

C++ documentation:

This property holds the frame shadow value from the frame style

Access functions:

Shadow frameShadow() const
void setFrameShadow(Shadow)

See also frameStyle() and frameShape().

pub unsafe fn set_frame_shape(&self, arg1: Shape)[src]

This property holds the frame shape value from the frame style

Calls C++ function: void QFrame::setFrameShape(QFrame::Shape arg1).

C++ documentation:

This property holds the frame shape value from the frame style

Access functions:

Shape frameShape() const
void setFrameShape(Shape)

See also frameStyle() and frameShadow().

pub unsafe fn set_frame_style(&self, arg1: c_int)[src]

Sets the frame style to style.

Calls C++ function: void QFrame::setFrameStyle(int arg1).

C++ documentation:

Sets the frame style to style.

The style is the bitwise OR between a frame shape and a frame shadow style. See the picture of the frames in the main class documentation.

The frame shapes are given in QFrame::Shape and the shadow styles in QFrame::Shadow.

If a mid-line width greater than 0 is specified, an additional line is drawn for Raised or Sunken Box, HLine, and VLine frames. The mid-color of the current color group is used for drawing middle lines.

See also frameStyle().

pub unsafe fn set_line_width(&self, arg1: c_int)[src]

This property holds the line width

Calls C++ function: void QFrame::setLineWidth(int arg1).

C++ documentation:

This property holds the line width

Note that the total line width for frames used as separators (HLine and VLine) is specified by frameWidth.

The default value is 1.

Access functions:

int lineWidth() const
void setLineWidth(int)

See also midLineWidth and frameWidth.

pub unsafe fn set_mid_line_width(&self, arg1: c_int)[src]

This property holds the width of the mid-line

Calls C++ function: void QFrame::setMidLineWidth(int arg1).

C++ documentation:

This property holds the width of the mid-line

The default value is 0.

Access functions:

int midLineWidth() const
void setMidLineWidth(int)

See also lineWidth and frameWidth.

pub unsafe fn size_hint(&self) -> CppBox<QSize>[src]

Reimplemented from QWidget::sizeHint().

Calls C++ function: virtual QSize QFrame::sizeHint() const.

C++ documentation:

Reimplemented from QWidget::sizeHint().

Trait Implementations

impl CppDeletable for QStackedWidget[src]

unsafe fn delete(&self)[src]

Destroys this stacked widget, and frees any allocated resources.

Calls C++ function: virtual [destructor] void QStackedWidget::~QStackedWidget().

C++ documentation:

Destroys this stacked widget, and frees any allocated resources.

impl Deref for QStackedWidget[src]

type Target = QFrame

The resulting type after dereferencing.

fn deref(&self) -> &QFrame[src]

Calls C++ function: QFrame* static_cast<QFrame*>(QStackedWidget* ptr).

impl DynamicCast<QStackedWidget> for QFrame[src]

unsafe fn dynamic_cast(ptr: Ptr<QFrame>) -> Ptr<QStackedWidget>[src]

Calls C++ function: QStackedWidget* dynamic_cast<QStackedWidget*>(QFrame* ptr).

impl DynamicCast<QStackedWidget> for QWidget[src]

unsafe fn dynamic_cast(ptr: Ptr<QWidget>) -> Ptr<QStackedWidget>[src]

Calls C++ function: QStackedWidget* dynamic_cast<QStackedWidget*>(QWidget* ptr).

impl DynamicCast<QStackedWidget> for QObject[src]

unsafe fn dynamic_cast(ptr: Ptr<QObject>) -> Ptr<QStackedWidget>[src]

Calls C++ function: QStackedWidget* dynamic_cast<QStackedWidget*>(QObject* ptr).

impl DynamicCast<QStackedWidget> for QPaintDevice[src]

unsafe fn dynamic_cast(ptr: Ptr<QPaintDevice>) -> Ptr<QStackedWidget>[src]

Calls C++ function: QStackedWidget* dynamic_cast<QStackedWidget*>(QPaintDevice* ptr).

impl StaticDowncast<QStackedWidget> for QFrame[src]

unsafe fn static_downcast(ptr: Ptr<QFrame>) -> Ptr<QStackedWidget>[src]

Calls C++ function: QStackedWidget* static_cast<QStackedWidget*>(QFrame* ptr).

impl StaticDowncast<QStackedWidget> for QWidget[src]

unsafe fn static_downcast(ptr: Ptr<QWidget>) -> Ptr<QStackedWidget>[src]

Calls C++ function: QStackedWidget* static_cast<QStackedWidget*>(QWidget* ptr).

impl StaticDowncast<QStackedWidget> for QObject[src]

unsafe fn static_downcast(ptr: Ptr<QObject>) -> Ptr<QStackedWidget>[src]

Calls C++ function: QStackedWidget* static_cast<QStackedWidget*>(QObject* ptr).

impl StaticDowncast<QStackedWidget> for QPaintDevice[src]

unsafe fn static_downcast(ptr: Ptr<QPaintDevice>) -> Ptr<QStackedWidget>[src]

Calls C++ function: QStackedWidget* static_cast<QStackedWidget*>(QPaintDevice* ptr).

impl StaticUpcast<QFrame> for QStackedWidget[src]

unsafe fn static_upcast(ptr: Ptr<QStackedWidget>) -> Ptr<QFrame>[src]

Calls C++ function: QFrame* static_cast<QFrame*>(QStackedWidget* ptr).

impl StaticUpcast<QObject> for QStackedWidget[src]

unsafe fn static_upcast(ptr: Ptr<QStackedWidget>) -> Ptr<QObject>[src]

Calls C++ function: QObject* static_cast<QObject*>(QStackedWidget* ptr).

impl StaticUpcast<QPaintDevice> for QStackedWidget[src]

unsafe fn static_upcast(ptr: Ptr<QStackedWidget>) -> Ptr<QPaintDevice>[src]

Calls C++ function: QPaintDevice* static_cast<QPaintDevice*>(QStackedWidget* ptr).

impl StaticUpcast<QWidget> for QStackedWidget[src]

unsafe fn static_upcast(ptr: Ptr<QStackedWidget>) -> Ptr<QWidget>[src]

Calls C++ function: QWidget* static_cast<QWidget*>(QStackedWidget* ptr).

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T, U> CastInto<U> for T where
    U: CastFrom<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> StaticUpcast<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.