Home · All Namespaces · All Classes · Grouped Classes · Modules · Functions codeless banner

Widget Class Reference
(QtUiTest::Widget)
[QtUiTestModule]

The Widget class provides an abstract base class for all test widgets. More...

This class is under development and is subject to change.

Public Functions

Signals


Detailed Description

The Widget class provides an abstract base class for all test widgets.

QtUiTest::Widget contains functionality which maps closely to QWidget. It encapsulates important information and functionality related to two-dimensional GUI elements.

All Qt Extended test widgets should implement the QtUiTest::Widget interface, using multiple inheritance to implement other QtUiTest interfaces where suitable.


Member Function Documentation

const QObjectList & Widget::children () const   [pure virtual]

Returns all children of this widget.

The returned objects may be actual QWidget instances, or may be wrapping test widgets. Therefore, the only safe way to use the returned objects are to cast them to the desired QtUiTest interface using qtuitest_cast.

Reimplementing this function allows widgets which are conceptually widgets but are not QObject subclasses to be wrapped. This can be achieved by returning a list of test widgets which do not necessarily have underlying QWidget instances.

See also QObject::children() and parent().

QRegion Widget::childrenVisibleRegion () const   [virtual]

Returns the currently on-screen, unobscured region of all child widgets of this widget, in widget coordinates. This does not include the visible region of this widget.

The base implementation calculates the visible region by calling visibleRegion() and childrenVisibleRegion() on all children().

See also QWidget::visibleRegion(), children(), and visibleRegion().

bool Widget::ensureVisiblePoint ( const QPoint & point )

Simulate whatever user input is necessary to ensure that point (in local coordinates) is on-screen and unobscured.

This convenience function calls ensureVisibleRegion() with a region containing only point.

Returns true if point was successfully made visible.

See also visibleRegion() and ensureVisibleRegion().

bool Widget::ensureVisibleRegion ( const QRegion & region )   [pure virtual]

Simulate whatever user input is necessary to ensure that region (in local coordinates) is on-screen and unobscured.

Returns true if region was successfully made visible.

See also visibleRegion().

void Widget::focusOutEvent ()   [virtual]

This function is called when this widget is about to lose keyboard focus. The base implementation does nothing.

This function should be reimplemented to put this widget in a state where subsequent up/down key clicks will result in non-destructive navigation between widgets.

For example, if this function is called on a combo box which currently has a list popped up, it should dismiss the list so that subsequent key clicks will navigate between widgets rather than navigating within the list.

    void MyComboBox::focusOutEvent() {
        // Assuming q is a QComboBox...
        // If the list is currently popped up...
        if (q->view()->isVisible()) {
            // Press the Select key to commit the currently highlighted
            // item and ensure we are ready to navigate by keys.
            QtUiTest::keyClick(Qt::Key_Select);
        }
    }

See also QWidget::focusOutEvent(), setFocus(), and hasFocus().

const QRect & Widget::geometry () const   [pure virtual]

Returns the geometry of this widget in parent coordinates.

See also QWidget::geometry().

void Widget::gotFocus ()   [signal]

This signal is emitted when this widget gains focus by any means.

See also QApplication::focusChanged().

bool Widget::hasEditFocus () const   [pure virtual]

Returns true if this widget currently has edit focus.

The concept of edit focus only exists in Qt Embedded. This function must be implemented on Qt Embedded. On other platforms, the base implementation will return the same as hasFocus().

See also QWidget::hasEditFocus() and setEditFocus().

bool Widget::hasFocus () const   [pure virtual]

Returns true if this widget currently has keyboard focus.

See also QWidget::hasFocus().

bool Widget::inherits ( QtUiTest::WidgetType type ) const   [virtual]

Returns true if this widget is of the given type.

The base implementation always returns false.

bool Widget::isVisible () const   [pure virtual]

Returns true if this widget is currently visible.

In this context, "visible" has the same meaning as in QWidget::isVisible(). Therefore, this function returning true is not a guarantee that this widget is currently on screen and unobscured. To test this, visibleRegion() can be used.

See also QWidget::isVisible() and visibleRegion().

QPoint Widget::mapFromGlobal ( const QPoint & pos ) const   [pure virtual]

Maps pos from global screen coordinates to widget coordinates and returns the result.

See also QWidget::mapFromGlobal().

QPoint Widget::mapToGlobal ( const QPoint & pos ) const   [pure virtual]

Maps pos from widget coordinates to global screen coordinates and returns the result.

See also QWidget::mapToGlobal().

QObject * Widget::parent () const   [pure virtual]

Returns the parent of this widget, or 0 if this widget has no parent.

The returned object may be an actual QWidget, or may be a wrapping test widget. Therefore, the only safe way to use the returned value of this function is to cast it to the desired QtUiTest interface using qtuitest_cast.

See also QObject::parent(), QWidget::parentWidget(), and children().

QRect Widget::rect () const   [virtual]

Returns the bounding rect of this widget in widget coordinates.

The base implementation returns geometry(), transformed to widget coordinates.

See also QWidget::rect().

bool Widget::setEditFocus ( bool enable )   [pure virtual]

Simulate the user input necessary to enable or disable edit focus for this widget. Enabling edit focus will implicitly call setFocus() when necessary.

The concept of edit focus only exists in Qt Embedded. This function must be implemented when using Qt Embedded. On other platforms, this function will behave the same as setFocus() when enable is true, and will have no effect when enable is false.

Returns true if edit focus was successfully enabled or disabled for this widget, false otherwise.

See also QWidget::setEditFocus() and hasEditFocus().

bool Widget::setFocus ()   [virtual]

Simulate the user input necessary to move keyboard focus to this widget.

The base implementation uses the result of hasFocus() to determine if the widget currently has focus. If in keypad mode, a sequence of Up or Down key presses will be used to move focus until this widget has focus. If in mouse mode, the center of this widget will be clicked once.

Due to the way this function works in keypad mode, it is very important that focusOutEvent() is correctly implemented for all widgets to dismiss any "grab" effects on keyboard focus.

When reimplementing this function, it is necessary to call focusOutEvent() on any widget before taking any action which could cause that widget to lose focus.

Returns true if focus was successfully given to this widget, false otherwise.

See also hasFocus(), QWidget::setFocus(), and focusOutEvent().

QRegion Widget::visibleRegion () const   [pure virtual]

Returns the currently on-screen, unobscured region of this widget, in widget coordinates.

See also QWidget::visibleRegion().

Qt::WindowFlags Widget::windowFlags () const   [virtual]

Returns the flags set on this widget.

The default implementation returns 0, which is equivalent to a plain Qt::Widget with no special flags set.

QString Widget::windowTitle () const   [virtual]

Returns the window title (caption).

The returned string will typically be empty for all widgets other than top-level widgets.

The default implementation returns an empty string.

See also QWidget::windowTitle().


Copyright © 2009 Trolltech Trademarks
Qt Extended 4.4.3