CopperSpice API
1.9.2
|
Base class for all user interface controls. More...
Public Typedefs | |
using | RenderFlags = QFlags< RenderFlag > |
Public Types | |
enum | RenderFlag |
Public Types inherited from QPaintDevice | |
enum | PaintDeviceMetric |
Public Signals | |
void | customContextMenuRequested (const QPoint &pos) |
void | windowIconChanged (const QIcon &icon) |
void | windowIconTextChanged (const QString &iconText) |
void | windowTitleChanged (const QString &title) |
Public Signals inherited from QObject | |
void | destroyed (QObject *obj=nullptr) |
void | objectNameChanged (const QString &objectName) |
Public Slots | |
bool | close () |
void | hide () |
void | lower () |
void | raise () |
void | repaint () |
void | setDisabled (bool disable) |
void | setEnabled (bool enable) |
void | setFocus () |
void | setHidden (bool hidden) |
void | setStyleSheet (const QString &styleSheet) |
virtual void | setVisible (bool visible) |
void | setWindowModified (bool modified) |
void | setWindowTitle (const QString &title) |
void | show () |
void | showFullScreen () |
void | showMaximized () |
void | showMinimized () |
void | showNormal () |
void | update () |
Public Slots inherited from QObject | |
void | deleteLater () |
Public Methods | |
QWidget (QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::EmptyFlag) | |
~QWidget () | |
bool | acceptDrops () const |
QString | accessibleDescription () const |
QString | accessibleName () const |
QList< QAction * > | actions () const |
void | activateWindow () |
void | addAction (QAction *action) |
void | addActions (const QList< QAction * > &actions) |
void | adjustSize () |
bool | autoFillBackground () const |
QPalette::ColorRole | backgroundRole () const |
QBackingStore * | backingStore () const |
QSize | baseSize () const |
QWidget * | childAt (const QPoint &position) const |
QWidget * | childAt (int x, int y) const |
QRect | childrenRect () const |
QRegion | childrenRegion () const |
void | clearFocus () |
void | clearMask () |
QMargins | contentsMargins () const |
QRect | contentsRect () const |
Qt::ContextMenuPolicy | contextMenuPolicy () const |
QCursor | cursor () const |
WId | effectiveWinId () const |
void | ensurePolished () const |
Qt::FocusPolicy | focusPolicy () const |
QWidget * | focusProxy () const |
QWidget * | focusWidget () const |
const QFont & | font () const |
QFontInfo | fontInfo () const |
QFontMetrics | fontMetrics () const |
QPalette::ColorRole | foregroundRole () const |
QRect | frameGeometry () const |
QSize | frameSize () const |
const QRect & | geometry () const |
void | getContentsMargins (int *left, int *top, int *right, int *bottom) const |
QPixmap | grab (const QRect &rectangle=QRect (QPoint (0, 0), QSize (-1,-1))) |
void | grabGesture (Qt::GestureType gestureType, Qt::GestureFlags flags=Qt::GestureFlags ()) |
void | grabKeyboard () |
void | grabMouse () |
void | grabMouse (const QCursor &cursor) |
int | grabShortcut (const QKeySequence &key, Qt::ShortcutContext context=Qt::WindowShortcut) |
QGraphicsEffect * | graphicsEffect () const |
QGraphicsProxyWidget * | graphicsProxyWidget () const |
bool | hasEditFocus () const |
bool | hasFocus () const |
virtual bool | hasHeightForWidth () const |
bool | hasMouseTracking () const |
int | height () const |
virtual int | heightForWidth (int width) const |
Qt::InputMethodHints | inputMethodHints () const |
virtual QVariant | inputMethodQuery (Qt::InputMethodQuery query) const |
void | insertAction (QAction *before, QAction *action) |
void | insertActions (QAction *before, QList< QAction * > actions) |
bool | isActiveWindow () const |
bool | isAncestorOf (const QWidget *child) const |
bool | isEnabled () const |
bool | isEnabledTo (const QWidget *parent) const |
bool | isEnabledToTLW () const |
bool | isFullScreen () const |
bool | isHidden () const |
bool | isMaximized () const |
bool | isMinimized () const |
bool | isModal () const |
bool | isTopLevel () const |
bool | isVisible () const |
bool | isVisibleTo (const QWidget *parent) const |
bool | isWindow () const |
bool | isWindowModified () const |
QLayout * | layout () const |
Qt::LayoutDirection | layoutDirection () const |
QLocale | locale () const |
QPoint | mapFrom (const QWidget *parent, const QPoint &pos) const |
QPoint | mapFromGlobal (const QPoint &pos) const |
QPoint | mapFromParent (const QPoint &pos) const |
QPoint | mapTo (const QWidget *parent, const QPoint &pos) const |
QPoint | mapToGlobal (const QPoint &pos) const |
QPoint | mapToParent (const QPoint &pos) const |
QRegion | mask () const |
int | maximumHeight () const |
QSize | maximumSize () const |
int | maximumWidth () const |
int | minimumHeight () const |
QSize | minimumSize () const |
virtual QSize | minimumSizeHint () const |
int | minimumWidth () const |
void | move (const QPoint &point) |
void | move (int x, int y) |
QWidget * | nativeParentWidget () const |
QWidget * | nextInFocusChain () const |
QRect | normalGeometry () const |
void | overrideWindowFlags (Qt::WindowFlags flags) |
QPaintEngine * | paintEngine () const override |
const QPalette & | palette () const |
QWidget * | parentWidget () const |
QPoint | pos () const |
QWidget * | previousInFocusChain () const |
QRect | rect () const |
void | releaseKeyboard () |
void | releaseMouse () |
void | releaseShortcut (int id) |
void | removeAction (QAction *action) |
void | render (QPaintDevice *target, const QPoint &targetOffset=QPoint (), const QRegion &sourceRegion=QRegion (), RenderFlags renderFlags=RenderFlags (DrawWindowBackground|DrawChildren)) |
void | render (QPainter *painter, const QPoint &targetOffset=QPoint (), const QRegion &sourceRegion=QRegion (), RenderFlags renderFlags=RenderFlags (DrawWindowBackground|DrawChildren)) |
void | repaint (const QRect &rect) |
void | repaint (const QRegion ®ion) |
void | repaint (int x, int y, int w, int h) |
void | resize (const QSize &size) |
void | resize (int w, int h) |
bool | restoreGeometry (const QByteArray &geometry) |
QByteArray | saveGeometry () const |
void | scroll (int dx, int dy) |
void | scroll (int dx, int dy, const QRect &rect) |
void | setAcceptDrops (bool on) |
void | setAccessibleDescription (const QString &description) |
void | setAccessibleName (const QString &name) |
void | setAttribute (Qt::WidgetAttribute attribute, bool enable=true) |
void | setAutoFillBackground (bool enable) |
void | setBackgroundRole (QPalette::ColorRole role) |
void | setBaseSize (const QSize &size) |
void | setBaseSize (int basew, int baseh) |
void | setContentsMargins (const QMargins &margins) |
void | setContentsMargins (int left, int top, int right, int bottom) |
void | setContextMenuPolicy (Qt::ContextMenuPolicy policy) |
void | setCursor (const QCursor &cursor) |
void | setEditFocus (bool enable) |
void | setFixedHeight (int h) |
void | setFixedSize (const QSize &size) |
void | setFixedSize (int w, int h) |
void | setFixedWidth (int w) |
void | setFocus (Qt::FocusReason reason) |
void | setFocusPolicy (Qt::FocusPolicy policy) |
void | setFocusProxy (QWidget *widget) |
void | setFont (const QFont &font) |
void | setForegroundRole (QPalette::ColorRole role) |
void | setGeometry (const QRect &rect) |
void | setGeometry (int x, int y, int w, int h) |
void | setGraphicsEffect (QGraphicsEffect *effect) |
void | setInputMethodHints (Qt::InputMethodHints hints) |
void | setLayout (QLayout *layout) |
void | setLayoutDirection (Qt::LayoutDirection direction) |
void | setLocale (const QLocale &locale) |
void | setMask (const QBitmap &bitmap) |
void | setMask (const QRegion ®ion) |
void | setMaximumHeight (int maxh) |
void | setMaximumSize (const QSize &size) |
void | setMaximumSize (int maxw, int maxh) |
void | setMaximumWidth (int maxw) |
void | setMinimumHeight (int minh) |
void | setMinimumSize (const QSize &size) |
void | setMinimumSize (int minw, int minh) |
void | setMinimumWidth (int minw) |
void | setMouseTracking (bool enable) |
void | setPalette (const QPalette &palette) |
void | setParent (QWidget *parent) |
void | setParent (QWidget *parent, Qt::WindowFlags flags) |
void | setShortcutAutoRepeat (int id, bool enable=true) |
void | setShortcutEnabled (int id, bool enable=true) |
void | setSizeIncrement (const QSize &size) |
void | setSizeIncrement (int w, int h) |
void | setSizePolicy (QSizePolicy policy) |
void | setSizePolicy (QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical) |
void | setStatusTip (const QString &data) |
void | setStyle (QStyle *style) |
void | setToolTip (const QString &data) |
void | setToolTipDuration (int msec) |
void | setUpdatesEnabled (bool enable) |
void | setWhatsThis (const QString &str) |
void | setWindowFilePath (const QString &filePath) |
void | setWindowFlags (Qt::WindowFlags flags) |
void | setWindowIcon (const QIcon &icon) |
void | setWindowModality (Qt::WindowModality windowModality) |
void | setWindowOpacity (qreal level) |
void | setWindowRole (const QString &role) |
void | setWindowState (Qt::WindowStates windowState) |
QSize | size () const |
virtual QSize | sizeHint () const |
QSize | sizeIncrement () const |
QSizePolicy | sizePolicy () const |
void | stackUnder (QWidget *widget) |
QString | statusTip () const |
QStyle * | style () const |
QString | styleSheet () const |
bool | testAttribute (Qt::WidgetAttribute attribute) const |
QString | toolTip () const |
int | toolTipDuration () const |
QWidget * | topLevelWidget () const |
bool | underMouse () const |
void | ungrabGesture (Qt::GestureType gestureType) |
void | unsetCursor () |
void | unsetLayoutDirection () |
void | unsetLocale () |
void | update (const QRect &rect) |
void | update (const QRegion ®ion) |
void | update (int x, int y, int w, int h) |
void | updateGeometry () |
bool | updatesEnabled () const |
QRegion | visibleRegion () const |
QString | whatsThis () const |
int | width () const |
QWidget * | window () const |
QString | windowFilePath () const |
Qt::WindowFlags | windowFlags () const |
QWindow * | windowHandle () const |
QIcon | windowIcon () const |
Qt::WindowModality | windowModality () const |
qreal | windowOpacity () const |
QString | windowRole () const |
Qt::WindowStates | windowState () const |
QString | windowTitle () const |
Qt::WindowType | windowType () const |
WId | winId () const |
int | x () const |
int | y () const |
Public Methods inherited from QObject | |
QObject (QObject *parent=nullptr) | |
~QObject () | |
bool | blockSignals (bool block) |
const QList< QObject * > & | children () const |
bool | connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
bool | connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
bool | disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const |
bool | disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const |
bool | disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const |
void | dumpObjectInfo () |
void | dumpObjectTree () |
QList< QString > | dynamicPropertyNames () const |
virtual bool | event (QEvent *event) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
template<typename T > | |
T | findChild (const QString &childName=QString ()) const |
template<class T > | |
QList< T > | findChildren (const QRegularExpression ®Exp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
template<class T > | |
QList< T > | findChildren (const QString &childName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
bool | inherits (const QString &className) const |
void | installEventFilter (QObject *filterObj) |
bool | isWidgetType () const |
bool | isWindowType () const |
void | killTimer (int id) |
const QMetaObject * | metaObject () const |
void | moveToThread (QThread *targetThread) |
QString | objectName () const |
QObject * | parent () const |
template<class T = QVariant> | |
T | property (const QString &name) const |
void | removeEventFilter (QObject *obj) |
void | setObjectName (const QString &name) |
void | setParent (QObject *parent) |
bool | setProperty (const QString &name, const QVariant &value) |
bool | signalsBlocked () const |
int | startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer) |
QThread * | thread () const |
Public Methods inherited from QPaintDevice | |
virtual | ~QPaintDevice () |
int | colorCount () const |
int | depth () const |
int | devicePixelRatio () const |
qreal | devicePixelRatioF () const |
int | height () const |
int | heightMM () const |
int | logicalDpiX () const |
int | logicalDpiY () const |
bool | paintingActive () const |
int | physicalDpiX () const |
int | physicalDpiY () const |
int | width () const |
int | widthMM () const |
Static Public Methods | |
static QWidget * | createWindowContainer (QWindow *window, QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::EmptyFlag) |
static QWidget * | find (WId id) |
static QWidget * | keyboardGrabber () |
static QWidget * | mouseGrabber () |
static void | setTabOrder (QWidget *firstWidget, QWidget *secondWidget) |
Static Public Methods inherited from QObject | |
static bool | connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
static bool | connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ()) |
static bool | connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn > | |
static bool | connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T > | |
static bool | connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection) |
static bool | disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod) |
static bool | disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod) |
static bool | disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod) |
static bool | disconnect (const QObject *sender, std::nullptr_t, const QObject *receiver, std::nullptr_t) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn > | |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...)) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver > | |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T > | |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod) |
static QMetaObject & | staticMetaObject () |
static QString | tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >()) |
Protected Slots | |
void | updateMicroFocus () |
Protected Methods | |
virtual void | actionEvent (QActionEvent *event) |
virtual void | changeEvent (QEvent *event) |
virtual void | closeEvent (QCloseEvent *event) |
virtual void | contextMenuEvent (QContextMenuEvent *event) |
void | create (WId window=0, bool initializeWindow=true, bool destroyOldWindow=true) |
void | destroy (bool destroyWindow=true, bool destroySubWindows=true) |
virtual void | dragEnterEvent (QDragEnterEvent *event) |
virtual void | dragLeaveEvent (QDragLeaveEvent *event) |
virtual void | dragMoveEvent (QDragMoveEvent *event) |
virtual void | dropEvent (QDropEvent *event) |
virtual void | enterEvent (QEvent *event) |
bool | event (QEvent *event) override |
virtual void | focusInEvent (QFocusEvent *event) |
bool | focusNextChild () |
virtual bool | focusNextPrevChild (bool next) |
virtual void | focusOutEvent (QFocusEvent *event) |
bool | focusPreviousChild () |
virtual void | hideEvent (QHideEvent *event) |
void | initPainter (QPainter *painter) const override |
virtual void | inputMethodEvent (QInputMethodEvent *event) |
virtual void | keyPressEvent (QKeyEvent *event) |
virtual void | keyReleaseEvent (QKeyEvent *event) |
virtual void | leaveEvent (QEvent *event) |
int | metric (PaintDeviceMetric metric) const override |
virtual void | mouseDoubleClickEvent (QMouseEvent *event) |
virtual void | mouseMoveEvent (QMouseEvent *event) |
virtual void | mousePressEvent (QMouseEvent *event) |
virtual void | mouseReleaseEvent (QMouseEvent *event) |
virtual void | moveEvent (QMoveEvent *event) |
virtual bool | nativeEvent (const QByteArray &eventType, void *message, long *result) |
virtual void | paintEvent (QPaintEvent *event) |
virtual void | resizeEvent (QResizeEvent *event) |
virtual void | showEvent (QShowEvent *event) |
virtual void | tabletEvent (QTabletEvent *event) |
virtual void | wheelEvent (QWheelEvent *event) |
Protected Methods inherited from QObject | |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const QMetaMethod &signalMethod) const |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const QMetaMethod &signalMethod) const |
bool | isSignalConnected (const QMetaMethod &signalMethod) const |
int | receivers (const QString &signal) const |
QObject * | sender () const |
int | senderSignalIndex () const |
virtual void | timerEvent (QTimerEvent *event) |
Protected Methods inherited from QPaintDevice | |
QPaintDevice () | |
Related Functions | |
These are not member functions | |
QWidgetList | |
WId | |
Related Functions inherited from QObject | |
T | qobject_cast (QObject *object) |
QObjectList | |
The QWidget class is the base class of all user interface controls. A widget is the fundamental building block used to create a user interface. This class receives mouse, keyboard and other events from the windowing system and is responsible for rendering the user interface controls on the screen. The user interface controls such as a push button or a text edit are called widgets. They are sorted in a Z order so the user can press the tab key to transition from one widget to the next.
A widget which does not have a parent is called a window. A window typically has a frame and a title bar although it is possible to create a window without these elements by using window flags. The QMainWindow and the various subclasses of QDialog are the most common window types.
Every constructor for a widget can accept one or two arguments.
QWidget has numerous methods which are not used directly by this class. For example, the font property is not used internally in QWidget. There are many subclasses which provide implementations which need a font such as QLabel, QPushButton, QListWidget, and QTabWidget.
A widget without a parent widget is always an independent window (top-level widget). For these widgets, setWindowTitle() and setWindowIcon() set the title bar and icon respectively.
Non-window widgets are child widgets, displayed within their parent widgets. Most widgets in CopperSpice are mainly useful as child widgets. For example, it is possible to display a button as a top-level window, but most people prefer to put their buttons inside other widgets, such as QDialog.
The diagram above shows a QGroupBox widget being used to hold various child widgets in a layout provided by QGridLayout. The QLabel child widgets have been outlined to indicate their full sizes.
If you want to use a QWidget to hold child widgets you will usually want to add a layout to the parent QWidget. Refer to Layout Management for more information.
When a widget is used as a container to group a number of child widgets, it is known as a composite widget. These can be created by constructing a widget with the required visual properties, like a QFrame for example, and adding child widgets to it, usually managed by a layout. The above diagram shows such a composite widget that was created using CS Designer.
Composite widgets can also be created by subclassing a standard widget, such as QWidget or QFrame, and adding the necessary layout and child widgets in the constructor of the subclass.
Since QWidget is a subclass of QPaintDevice, subclasses can be used to display custom content that is composed using a series of painting operations with an instance of the QPainter class. This approach contrasts with the canvas-style approach used by the Graphics View System where items are added to a scene by the application and are rendered by CopperSpice itself.
Each widget performs all painting operations from within its paintEvent() method. This is called whenever the widget needs to be redrawn, either as a result of some external change or when requested by the application.
When implementing a new widget, it is almost always useful to reimplement sizeHint() to provide a reasonable default size for the widget and to set the correct size policy with setSizePolicy().
By default, composite widgets which do not provide a size hint will be sized according to the space requirements of their child widgets.
The size policy lets you supply good default behavior for the layout management system, so that other widgets can contain and manage yours easily. The default size policy indicates that the size hint represents the preferred size of the widget, and this is often good enough for many widgets.
Widgets respond to events that are typically caused by user actions. CopperSpice delivers events to widgets by calling specific event handler methods with instances of QEvent subclasses containing information about each event. If your widget only contains child widgets you probably do not need to implement any event handlers. If you want to detect a mouse click in a child widget call the child's underMouse() method inside the widget's mousePressEvent().
You will need to supply the behavior and content for your own widgets. The following is a an overview of the events that are relevant to QWidget.
Widgets that accept keyboard input need to reimplement additional more event handlers.
You may be required to also reimplement some of the less common event handlers as listed below.
There are also some rather obscure events described in the documentation for QEvent::Type. To handle these events, you need to reimplement event() directly. The default implementation of event() handles Tab and Shift+Tab (to move the keyboard focus), and passes on most of the other events to one of the more specialized handlers above.
Events and the mechanism used to deliver them are covered in The Event System.
In addition to the standard widget styles for each platform, widgets can also be styled according to rules specified in a style sheet. This feature enables you to customize the appearance of specific widgets to provide visual cues to users about their purpose. For example, a button could be styled in a particular way to indicate that it performs a destructive action.
The use of widget style sheets is described in more detail in CopperSpice Style Sheets.
QWidget automatically double-buffers its painting, so there is no need to write double-buffering code in paintEvent() to avoid flicker.
The Qt::WA_ContentsPropagated widget attribute has been deprecated. Instead, the contents of parent widgets are propagated by default to each of their children as long as Qt::WA_PaintOnScreen is not set. Custom widgets can be written to take advantage of this feature by updating irregular regions (to create non-rectangular child widgets), or painting with colors that have less than full alpha component. The following diagram shows how attributes and properties of a custom widget can be fine-tuned to achieve different effects.
In the above diagram, a semi-transparent rectangular child widget with an area removed is constructed and added to a parent widget (a QLabel showing a pixmap). Then, different properties and widget attributes are set to achieve different effects:
To rapidly update custom widgets with simple background colors, such as real-time plotting or graphing widgets, it is better to define a suitable background color (using setBackgroundRole() with the QPalette::Window role), set the autoFillBackground property, and only implement the necessary drawing functionality in the widget's paintEvent().
To rapidly update custom widgets that constantly paint over their entire areas with opaque content, e.g., video streaming widgets, it is better to set the widget's Qt::WA_OpaquePaintEvent, avoiding any unnecessary overhead associated with repainting the widget's background.
If a widget has both the Qt::WA_OpaquePaintEvent widget attribute and the autoFillBackground property set, the Qt::WA_OpaquePaintEvent attribute takes precedence. Depending on your requirements, you should choose either one of them.
The contents of parent widgets are also propagated to standard CopperSpice widgets. This can lead to some unexpected results if the parent widget is decorated in a non-standard way, as shown in the diagram below.
The scope for customizing the painting behavior of standard CopperSpice widgets, without resorting to subclassing, is slightly less than that possible for custom widgets. Usually, the desired appearance of a standard widget can be achieved by setting its autoFillBackground property.
It is possible to create windows with translucent regions on window systems that support compositing.
To enable this feature in a top-level widget, set its Qt::WA_TranslucentBackground attribute with setAttribute() and ensure that its background is painted with non-opaque colors in the regions you want to be partially transparent.
Platform notes:
Alien widgets are widgets unknown to the windowing system. They do not have a native window handle associated with them. This feature significantly speeds up widget painting, resizing, and removes flicker.
Should you require the old behavior with native windows, you can choose one of the following options:
QT_USE_NATIVE_WINDOWS=1
in your environment. Typedef for QFlags<RenderFlag> which contains an OR combination of RenderFlag values.
Refer to QWidget::RenderFlag for the enum documentation.
enum QWidget::RenderFlag |
This enum describes how to render the widget when calling QWidget::render().
Constant | Value | Description |
---|---|---|
QWidget::DrawWindowBackground | 0x1 | If you enable this option the widget's background is rendered into the target even if autoFillBackground is not set. By default, this option is enabled. |
QWidget::DrawChildren | 0x2 | If you enable this option, the widget's children are rendered recursively into the target. By default, this option is enabled. |
QWidget::IgnoreMask | 0x4 | If you enable this option, the widget's QWidget::mask() is ignored when rendering into the target. By default, this option is disabled. |
|
explicit |
Constructs a widget which is a child of parent, with widget flags set to flags. If parent is nullptr the new widget becomes a window. If parent is another widget, this widget becomes a child window inside parent. The new widget is deleted when its parent is deleted.
The widget flags argument f is normally 0, but it can be set to customize the frame of a window (i.e. parent must be nullptr). To customize the frame use a value composed from the bitwise OR of any of the window flags.
If you add a child widget to an already visible widget you must explicitly show the child to make it visible.
The X11 version of CopperSpice may not be able to deliver all combinations of style flags on all systems. This occurs because CopperSpice can only ask the window manager and the window manager can override the application's settings.
On Windows, CopperSpice can set whatever flags you want.
QWidget::~QWidget | ( | ) |
Destroys the widget.
All this widget's children are deleted first. The application exits if this widget is the main widget.
bool QWidget::acceptDrops | ( | ) | const |
Returns the value of the acceptDrops property.
QString QWidget::accessibleDescription | ( | ) | const |
Returns the value of the accessibleDescription property.
QString QWidget::accessibleName | ( | ) | const |
Returns the value of the accessibleName property.
|
protectedvirtual |
This event handler is called with the given event whenever the widget's actions are changed.
Reimplemented in QMenu::actionEvent(), QToolBar::actionEvent(), QToolButton::actionEvent(), QMenuBar::actionEvent()
Returns the (possibly empty) list of this widget's actions.
void QWidget::activateWindow | ( | ) |
Sets the top-level widget containing this widget to be the active window. An active window is a visible top-level window that has the keyboard input focus.
This method performs the same operation as clicking the mouse on the title bar of a top-level window. On X11, the result depends on the Window Manager. If you want to ensure that the window is stacked on top as well you should also call raise(). Note, the window must be visible otherwise activateWindow() has no effect.
On Windows, if you are calling this when the application is not currently the active one then it will not make it the active window. It will change the color of the taskbar entry to indicate that the window has changed in some way. This is because Microsoft does not allow an application to interrupt what the user is currently doing in another application.
void QWidget::addAction | ( | QAction * | action | ) |
Appends action to the list of existing actions available for this widget. A QAction list is typically used to create a context QMenu, however it can be represented in different ways depending on the widget.
A QWidget should only have one of each action. Adding an action which already exists will not cause the same action to be in the widget multiple times. The ownership of action is not transferred to this QWidget.
Appends the given actions to this widget's list of actions.
void QWidget::adjustSize | ( | ) |
Adjusts the size of the widget to fit its contents.
This method uses sizeHint() if it is valid, for example the size hint's width and height are >= 0. Otherwise, it sets the size to the children rectangle that covers all child widgets (the union of all child widget rectangles).
For windows, the screen size is also taken into account. If the sizeHint() is less than (200, 100) and the size policy is expanding, the window will be at least (200, 100). The maximum size of a window is 2/3 of the screen's width and height.
bool QWidget::autoFillBackground | ( | ) | const |
Returns the value of the autoFillBackground property.
QPalette::ColorRole QWidget::backgroundRole | ( | ) | const |
Returns the background role of the widget. The background role defines the brush from the widget's palette that is used to render the background.
If no explicit background role is set the widget inherits its parent widget's background role.
QBackingStore * QWidget::backingStore | ( | ) | const |
Returns the QBackingStore this widget will be drawn into.
QSize QWidget::baseSize | ( | ) | const |
Returns the value of the baseSize property.
|
protectedvirtual |
This event handler can be reimplemented to handle state changes. The state being changed in this event can be retrieved through the event supplied.
Reimplemented in QTextEdit::changeEvent(), QPlainTextEdit::changeEvent(), QFileDialog::changeEvent(), QLineEdit::changeEvent(), QMessageBox::changeEvent(), QComboBox::changeEvent(), QTabBar::changeEvent(), QMenu::changeEvent(), QTabWidget::changeEvent(), QToolBar::changeEvent(), QAbstractSpinBox::changeEvent(), QWebView::changeEvent(), QAbstractSlider::changeEvent(), QAbstractButton::changeEvent(), QLabel::changeEvent(), QDialogButtonBox::changeEvent(), QProgressDialog::changeEvent(), QDockWidget::changeEvent(), QToolButton::changeEvent(), QFrame::changeEvent(), QSplitter::changeEvent(), QMenuBar::changeEvent(), QColorDialog::changeEvent(), QFontDialog::changeEvent(), QGroupBox::changeEvent(), QToolBox::changeEvent(), QRubberBand::changeEvent(), QErrorMessage::changeEvent(), QMdiSubWindow::changeEvent()
QWidget * QWidget::childAt | ( | const QPoint & | position | ) | const |
Returns the visible child widget at point position in the widget's own coordinate system.
|
inline |
Returns the visible child widget at the position (x, y) in the widget's coordinate system. If there is no visible child widget at the specified position the method returns nullptr.
QRect QWidget::childrenRect | ( | ) | const |
Returns the value of the childrenRect property.
QRegion QWidget::childrenRegion | ( | ) | const |
Returns the value of the childrenRegion property.
void QWidget::clearFocus | ( | ) |
Removes keyboard input focus from the widget. If the widget has focus then a focusOutEvent is sent to the widget.
|
slot |
Closes this widget. Returns true if the widget was closed, otherwise returns false.
First it sends the widget a QCloseEvent. The widget is hidden if it accepts the close event. If it ignores the event, nothing happens. The default implementation of QWidget::closeEvent() accepts the close event.
If the widget has the Qt::WA_DeleteOnClose flag, the widget is also deleted. A close events is delivered to the widget no matter if the widget is visible or not.
The QApplication::lastWindowClosed() signal is emitted when the last visible primary window (i.e. window with no parent) with the Qt::WA_QuitOnClose attribute set is closed. By default this attribute is set for all widgets except transient windows such as splash screens, tool windows, and popup menus.
|
protectedvirtual |
This event handler is called with the given event when CopperSpice receives a window close request for a top-level widget from the window system.
By default, the event is accepted and the widget is closed. You can reimplement this method to change the way the widget responds to window close requests. For example, you can prevent the window from closing by calling ignore() on all events.
Main window applications typically use reimplementations of this method to check whether the user's work has been saved and ask for permission before closing.
Reimplemented in QMessageBox::closeEvent(), QAbstractSpinBox::closeEvent(), QProgressDialog::closeEvent(), QDockWidget::closeEvent(), QDialog::closeEvent(), QWebInspector::closeEvent(), QMdiSubWindow::closeEvent()
QMargins QWidget::contentsMargins | ( | ) | const |
The contentsMargins method returns the widget's contents margins.
QRect QWidget::contentsRect | ( | ) | const |
Returns the area inside the widget's margins.
|
protectedvirtual |
The event handler for the given event can be reimplemented in a subclass to receive widget context menu events. The handler is called when the widget's contextMenuPolicy is Qt::DefaultContextMenu.
The default implementation ignores the context event.
Reimplemented in QTextEdit::contextMenuEvent(), QComboBox::contextMenuEvent(), QPlainTextEdit::contextMenuEvent(), QLineEdit::contextMenuEvent(), QGraphicsView::contextMenuEvent(), QMainWindow::contextMenuEvent(), QAbstractSpinBox::contextMenuEvent(), QWebView::contextMenuEvent(), QLabel::contextMenuEvent(), QAbstractScrollArea::contextMenuEvent(), QDialog::contextMenuEvent(), QScrollBar::contextMenuEvent(), QMdiSubWindow::contextMenuEvent()
Qt::ContextMenuPolicy QWidget::contextMenuPolicy | ( | ) | const |
Returns the value of the contextMenuPolicy property.
|
protected |
Creates a new widget window if window is 0, otherwise sets the widget's window to window.
Initializes the window (sets the geometry etc.) if initializeWindow is true. If initializeWindow is false, no initialization is performed. This parameter only makes sense if window is a valid window.
Destroys the old window if destroyOldWindow is true. If destroyOldWindow is false, you are responsible for destroying the window yourself (using platform native code).
The QWidget constructor calls create(0,true,true) to create a window for this widget.
|
static |
Creates a new QWidget which contains the given window. The new QWidget will take ownership of the given window. The new QWidget is created as a child of parent and with the given window flags. Once the window has been embedded into the new QWidget, the widget will control the window's geometry and visibility. You should not call QWindow::setGeometry(), QWindow::show() or QWindow::hide() on the window. The window can be removed from the QWidget by calling QWindow::setParent().
The widget is attached as a native child window to the top level window it belongs to. When a widget is used as a child of QAbstractScrollArea or QMdiArea, it will create a native window for every widget in its parent chain to allow for proper stacking and clipping in this use case. Creating a native window for the widget also allows for proper stacking and clipping. This must be done before showing the widget. Applications with multiple native child windows may have minor performance issues.
The following is a list of known limitations.
QCursor QWidget::cursor | ( | ) | const |
Returns the value of the cursor property.
|
signal |
This signal is emitted when the widget's contextMenuPolicy is Qt::CustomContextMenu, and the user has requested a context menu on the widget. The position pos is the position of the context menu event that the widget receives. Normally this is in widget coordinates. The exception to this rule is QAbstractScrollArea and its subclasses that map the context menu event to coordinates of the viewport() .
|
protected |
Frees up window system resources. Destroys the widget window if destroyWindow is true. This method () calls itself recursively for all the child widgets, passing destroySubWindows for the destroyWindow parameter. To have more control over destruction of subwidgets, destroy subwidgets selectively first.
This method is usually called from the QWidget destructor.
|
protectedvirtual |
This event handler is called when a drag is in progress and the mouse enters this widget. The event is passed in the event parameter. If the event is ignored, the widget will not receive any drag move events.
Refer to the Drag and Drop documentation for an overview of how to provide drag and drop in your application.
Reimplemented in QAbstractItemView::dragEnterEvent(), QTextEdit::dragEnterEvent(), QPlainTextEdit::dragEnterEvent(), QGraphicsView::dragEnterEvent(), QLineEdit::dragEnterEvent(), QWebView::dragEnterEvent(), QAbstractScrollArea::dragEnterEvent()
|
protectedvirtual |
This event handler is called when a drag is in progress and the mouse leaves this widget. The event is passed in the event parameter.
Refer to the Drag and Drop documentation for an overview of how to provide drag and drop in your application.
Reimplemented in QAbstractItemView::dragLeaveEvent(), QTextEdit::dragLeaveEvent(), QPlainTextEdit::dragLeaveEvent(), QGraphicsView::dragLeaveEvent(), QLineEdit::dragLeaveEvent(), QListView::dragLeaveEvent(), QWebView::dragLeaveEvent(), QAbstractScrollArea::dragLeaveEvent()
|
protectedvirtual |
The event handler is called if a drag is in progress, and when any of the following conditions occur: the cursor enters this widget, the cursor moves within this widget, or a modifier key is pressed on the keyboard while this widget has the focus.
Refer to the Drag and Drop documentation for an overview of how to provide drag and drop in your application.
Reimplemented in QAbstractItemView::dragMoveEvent(), QTextEdit::dragMoveEvent(), QPlainTextEdit::dragMoveEvent(), QGraphicsView::dragMoveEvent(), QLineEdit::dragMoveEvent(), QTreeView::dragMoveEvent(), QListView::dragMoveEvent(), QWebView::dragMoveEvent(), QAbstractScrollArea::dragMoveEvent()
|
protectedvirtual |
This event handler is called when the drag is dropped on this widget.
Refer to the Drag and Drop documentation for an overview of how to provide drag and drop in your application.
Reimplemented in QTreeWidget::dropEvent(), QAbstractItemView::dropEvent(), QTableWidget::dropEvent(), QTextEdit::dropEvent(), QListWidget::dropEvent(), QPlainTextEdit::dropEvent(), QGraphicsView::dropEvent(), QLineEdit::dropEvent(), QListView::dropEvent(), QWebView::dropEvent(), QAbstractScrollArea::dropEvent()
WId QWidget::effectiveWinId | ( | ) | const |
Returns the effective window system identifier of the widget. For example, the native parent's window system identifier. If the widget is native, this method returns the native widget ID. Otherwise, the window ID of the first native parent widget, the top-level widget that contains this widget, is returned.
void QWidget::ensurePolished | ( | ) | const |
Ensures the widget has been polished by QStyle and has a proper font and palette.
QWidget calls this method after it has been fully constructed but before it is shown the very first time. You can call this method if you want to ensure that the widget is polished before doing an operation. For example, the correct font size might be needed in the widget's sizeHint() reimplementation. This method is called from the default implementation of sizeHint().
Polishing is useful for final initialization that must happen after all constructors (from base classes as well as from subclasses) have been called. If you need to change some settings when a widget is polished, reimplement event() and handle the QEvent::Polish event type.
|
protectedvirtual |
The event handler can be reimplemented in a subclass to receive widget enter events which are passed in the event parameter. An event is sent to the widget when the mouse cursor enters the widget.
Reimplemented in QMenu::enterEvent(), QToolButton::enterEvent()
|
overrideprotected |
This is the main event handler and it handles the given event. You can reimplement this method in a subclass, but we recommend using one of the specialized event handlers instead.
Key press and release events are treated differently from other events. event() checks for Tab and Shift+Tab and tries to move the focus appropriately. If there is no widget to move the focus to (or the key press is not Tab or Shift+Tab), event() calls keyPressEvent().
Mouse and tablet event handling is also slightly special: only when the widget is enabled, event() will call the specialized handlers such as mousePressEvent(), otherwise it will discard the event.
This method returns true if the event was recognized, otherwise it returns false. If the recognized event was accepted (see QEvent::accepted), any further processing such as event propagation to the parent widget stops.
|
static |
Returns a pointer to the widget with a window identifier or handle matching id.
The window identifier type depends on the underlying window system, see qwindowdefs.h
for the actual definition. If there is no widget with this identifier then nullptr is returned.
|
protectedvirtual |
This event handler can be reimplemented in a subclass to receive keyboard focus events for the widget. The default implementation updates the widget if a focusPolicy() is specified. The event is passed in the event parameter.
A widget normally must the setFocusPolicy() to something other than Qt::NoFocus in order to receive focus events.
Reimplemented in QMdiSubWindow::focusInEvent(), QAbstractItemView::focusInEvent(), QTextEdit::focusInEvent(), QPlainTextEdit::focusInEvent(), QGraphicsView::focusInEvent(), QComboBox::focusInEvent(), QLineEdit::focusInEvent(), QDateTimeEdit::focusInEvent(), QWebView::focusInEvent(), QAbstractSpinBox::focusInEvent(), QLabel::focusInEvent(), QAbstractButton::focusInEvent(), QMenuBar::focusInEvent(), QGroupBox::focusInEvent(), QPushButton::focusInEvent()
|
inlineprotected |
Move keyboard focus to the next widget and returns true if it can find a widget or false if it can not.
|
protectedvirtual |
Finds a new widget to give the keyboard focus to, as appropriate for Tab and Shift+Tab, and returns true if it can find a new widget, or false if it can not.
If next is true this method searches forward, if next is false it searches backward.
You may want to reimplement this method. For example, a web browser might reimplement it to move its "current active link" forward or backward, and call focusNextPrevChild() only when it reaches the last or first link on the "page".
Child widgets call focusNextPrevChild() on their parent widgets, but only the window that contains the child widgets decides where to redirect focus. By reimplementing this method for an object, you thus gain control of focus traversal for all child widgets.
Reimplemented in QAbstractItemView::focusNextPrevChild(), QTextEdit::focusNextPrevChild(), QGraphicsView::focusNextPrevChild(), QPlainTextEdit::focusNextPrevChild(), QMenu::focusNextPrevChild(), QDateTimeEdit::focusNextPrevChild(), QWebView::focusNextPrevChild(), QLabel::focusNextPrevChild(), QTextBrowser::focusNextPrevChild(), QScrollArea::focusNextPrevChild()
|
protectedvirtual |
This event handler can be reimplemented in a subclass to receive keyboard focus events for the widget. The default implementation updates the widget if a focusPolicy() is specified. The events is passed in the event parameter.
A widget normally must setFocusPolicy() to something other than Qt::NoFocus in order to receive focus events.
Reimplemented in QMdiSubWindow::focusOutEvent(), QAbstractItemView::focusOutEvent(), QTextEdit::focusOutEvent(), QPlainTextEdit::focusOutEvent(), QGraphicsView::focusOutEvent(), QComboBox::focusOutEvent(), QLineEdit::focusOutEvent(), QWebView::focusOutEvent(), QAbstractSpinBox::focusOutEvent(), QLabel::focusOutEvent(), QAbstractButton::focusOutEvent(), QTextBrowser::focusOutEvent(), QMenuBar::focusOutEvent(), QPushButton::focusOutEvent()
Qt::FocusPolicy QWidget::focusPolicy | ( | ) | const |
Returns the value of the focusPolicy property.
|
inlineprotected |
Move keyboard focus to the previous widget and returns true if it can find a widget or false if it can not.
QWidget * QWidget::focusProxy | ( | ) | const |
Returns the focus proxy or nullptr if there is no focus proxy.
QWidget * QWidget::focusWidget | ( | ) | const |
Returns the last child of this widget that setFocus had been called on. For top level widgets this is the widget that will get focus in case this window gets activated.
This is not the same as QApplication::focusWidget(), which returns the focus widget in the currently active window.
|
inline |
Returns the value of the font property.
|
inline |
Returns the font info for the widget's current font. Equivalent to calling QFontInto(widget->font()).
|
inline |
Returns the font metrics for the widget's current font. Equivalent to calling QFontMetrics(widget->font()).
QPalette::ColorRole QWidget::foregroundRole | ( | ) | const |
Returns the foreground role. The foreground role defines the color from the widget's palette that is used to draw the foreground.
If no explicit foreground role is set, the method returns a role that contrasts with the background role.
QRect QWidget::frameGeometry | ( | ) | const |
Returns the value of the frameGeometry property.
QSize QWidget::frameSize | ( | ) | const |
Returns the value of the frameSize property.
|
inline |
Returns the value of the geometry property.
void QWidget::getContentsMargins | ( | int * | left, |
int * | top, | ||
int * | right, | ||
int * | bottom | ||
) | const |
Returns the widget's contents margins for left, top, right, and bottom.
void QWidget::grabGesture | ( | Qt::GestureType | gestureType, |
Qt::GestureFlags | flags = Qt::GestureFlags() |
||
) |
Subscribes the widget to a given gestureType with specific flags.
void QWidget::grabKeyboard | ( | ) |
Grabs the keyboard input.
This widget will receive all keyboard events until releaseKeyboard() is called. No other widgets will receive any keyboard events. Mouse events are not affected by this call. Use grabMouse() to grab mouse events.
The focus widget is not affected except that it does not receive any keyboard events. The setFocus() method moves the focus as usual, but the new focus widget receives keyboard events only after releaseKeyboard() is called.
If a different widget is currently grabbing keyboard input, that widget's grab is released first.
void QWidget::grabMouse | ( | ) |
Grabs the mouse input. This widget receives all mouse events until releaseMouse() is called; other widgets get no mouse events at all. Keyboard events are not affected. Use grabKeyboard() if you want to grab that.
Problems in applications which grab the mouse can make the computer unresponsive. This method should be used with extreme caution.
It is almost never necessary to grab the mouse. CopperSpice grabs the mouse when a mouse button is pressed and keeps it until the last button is released. Only visible widgets can grab mouse input. If isVisible() returns false for a widget, that widget can not call grabMouse().
void QWidget::grabMouse | ( | const QCursor & | cursor | ) |
Grabs the mouse input and changes the cursor shape. The cursor will assume shape cursor and this widget will be the only one to receive mouse events until releaseMouse() is called().
int QWidget::grabShortcut | ( | const QKeySequence & | key, |
Qt::ShortcutContext | context = Qt::WindowShortcut |
||
) |
Adds a shortcut to the CopperSpice 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.
If the same key sequence has been grabbed by several widgets when the key sequence is pressed, a QEvent::Shortcut event is sent to all the widgets in a non-deterministic order. The QShortcutEvent::isAmbiguous() method will return true for this event.
QGraphicsEffect * QWidget::graphicsEffect | ( | ) | const |
The graphicsEffect method returns a pointer to the widget's graphics effect. If the widget has no graphics effect, a nullptr is returned.
QGraphicsProxyWidget * QWidget::graphicsProxyWidget | ( | ) | const |
Returns the proxy widget for the corresponding embedded widget in a graphics view, otherwise returns a nullptr.
bool QWidget::hasEditFocus | ( | ) | const |
Returns true if this widget currently has edit focus, otherwise false.
bool QWidget::hasFocus | ( | ) | const |
Returns the value of the hasFocus property.
|
virtual |
Returns true if the widget's preferred height depends on its width, otherwise returns false.
Reimplemented in QTabWidget::hasHeightForWidth()
|
inline |
Returns the value of the mouseTracking property.
|
inline |
Returns the value of the height property.
|
virtual |
Returns the preferred height for this widget, given the width.
If this widget has a layout, the default implementation returns the layout's preferred height. if there is no layout, the default implementation returns -1 indicating that the preferred height does not depend on the width.
Reimplemented in QTabWidget::heightForWidth(), QLabel::heightForWidth(), QMenuBar::heightForWidth(), QCommandLinkButton::heightForWidth()
|
slot |
Hides the widget. This method is equivalent to calling setVisible(false).
|
protectedvirtual |
The event handler can be reimplemented in a subclass to receive widget hide events. Hide events are sent to widgets immediately after they have been hidden.
Note: A widget receives spontaneous show and hide events when its mapping status is changed by the window system, e.g. a spontaneous hide event when the user minimizes the window, and a spontaneous show event when the window is restored again. After receiving a spontaneous hide event, a widget is still considered visible in the sense of isVisible().
Reimplemented in QMdiSubWindow::hideEvent(), QComboBox::hideEvent(), QMenu::hideEvent(), QTabBar::hideEvent(), QAbstractSpinBox::hideEvent(), QScrollBar::hideEvent(), QSizeGrip::hideEvent(), QWebInspector::hideEvent()
|
overrideprotectedvirtual |
Initializes the painter pen, background and font to the same as the given widget's. This method is called automatically when the painter is opened on a QWidget.
Reimplemented from QPaintDevice
|
protectedvirtual |
The event handler can be reimplemented in a subclass to receive Input Method composition events. This handler is called when the state of the input method changes.
When creating custom text editing widgets the Qt::WA_InputMethodEnabled window attribute must be set explicitly using the setAttribute() in order to receive input method events.
The default implementation calls event->ignore() which rejects the Input Method event.
Reimplemented in QAbstractItemView::inputMethodEvent(), QTextEdit::inputMethodEvent(), QPlainTextEdit::inputMethodEvent(), QGraphicsView::inputMethodEvent(), QComboBox::inputMethodEvent(), QLineEdit::inputMethodEvent(), QWebView::inputMethodEvent()
Qt::InputMethodHints QWidget::inputMethodHints | ( | ) | const |
Returns the value of the property.
|
virtual |
This method is only relevant for input widgets. It is used by the input method to query a set of properties of the widget to be able to support complex input method operations as support for surrounding text and reconversions.
The given query specifies which property is queried.
Reimplemented in QLineEdit::inputMethodQuery(), QAbstractItemView::inputMethodQuery(), QGraphicsView::inputMethodQuery(), QComboBox::inputMethodQuery(), QAbstractSpinBox::inputMethodQuery(), QTextEdit::inputMethodQuery(), QPlainTextEdit::inputMethodQuery(), QWebView::inputMethodQuery()
Inserts the action to the current QWidget list of actions before the action before. It appends the action if before is a nullptr or not a valid action for this widget. A QWidget should only have one of each action.
Inserts the actions to current QWidget before the action before. It appends the action if before is a nullptr or not a valid action for this widget. A QWidget can have at most one of each action.
bool QWidget::isActiveWindow | ( | ) | const |
Returns the value of the isActiveWindow property.
bool QWidget::isAncestorOf | ( | const QWidget * | child | ) | const |
Returns true if this widget is a parent, (or grandparent and so on to any level), of the given child, and both widgets are within the same window, otherwise returns false.
|
inline |
Returns the value of the enabled property.
bool QWidget::isEnabledTo | ( | const QWidget * | parent | ) | const |
Returns true if this widget would become enabled if parent is enabled, otherwise returns false. This is the case if neither the widget itself nor every parent up to but excluding ancestor has been explicitly disabled.
Calling isEnabledTo(0) is equivalent to calling isEnabled().
|
inlinedeprecated |
bool QWidget::isFullScreen | ( | ) | const |
Returns the value of the fullScreen property.
|
inline |
Returns true if the widget is hidden, otherwise returns false. A hidden widget will only become visible when show() is called on it. It will not be automatically shown when the parent is shown. To check visibility, use ! isVisible() instead (notice the exclamation mark).
isHidden() implies !isVisible(), but a widget can be not visible and not hidden at the same time. This is the case for widgets that are children of widgets that are not visible.
Widgets are hidden if:
bool QWidget::isMaximized | ( | ) | const |
Returns the value of the maximized property.
bool QWidget::isMinimized | ( | ) | const |
Returns the value of the minimized property.
|
inline |
Returns the value of the modal property.
|
inlinedeprecated |
|
inline |
Returns the value of the visible property.
bool QWidget::isVisibleTo | ( | const QWidget * | parent | ) | const |
Returns true if this widget would become visible if parent is shown, otherwise returns false. The true case occurs if neither the widget itself nor any parent up to but excluding ancestor has been explicitly hidden.
This method will still return true if the widget is obscured by other windows on the screen, but could be physically visible if it or they were to be moved.
isVisibleTo(0) is identical to isVisible().
|
inline |
Returns true if the widget is an independent window, otherwise returns false.
A window is a widget that is not visually the child of any other widget and that usually has a frame and a window title.
A window can have a parent widget. It will then be grouped with its parent and deleted when the parent is deleted, minimized when the parent is minimized etc. If supported by the window manager, it will also have a common taskbar entry with its parent.
QDialog and QMainWindow widgets are by default windows, even if a parent widget is specified in the constructor. This behavior is specified by the Qt::Window flag.
bool QWidget::isWindowModified | ( | ) | const |
Returns the value of the windowModified property.
|
static |
Returns the widget that is currently grabbing the keyboard input. If no widget in this application is currently grabbing the keyboard, nullptr is returned.
|
protectedvirtual |
The event handler for the given event can be reimplemented in a subclass to receive key press events for the widget. A widget must call setFocusPolicy() to accept focus initially and have focus in order to receive a key press event.
If you reimplement this handler it is very important to call the base class implementation if you do not act upon the key. A QKeyEvent starts with isAccepted() set to true so you do not need to call QKeyEvent::accept(). Do not call the base class implementation if you consume the key event.
The default implementation closes popup widgets if the user presses Esc, otherwise the event is ignored and the widget's parent can react to it.
Reimplemented in QMdiSubWindow::keyPressEvent(), QAbstractItemView::keyPressEvent(), QTextEdit::keyPressEvent(), QGraphicsView::keyPressEvent(), QComboBox::keyPressEvent(), QPlainTextEdit::keyPressEvent(), QMessageBox::keyPressEvent(), QLineEdit::keyPressEvent(), QMenu::keyPressEvent(), QTabBar::keyPressEvent(), QDateTimeEdit::keyPressEvent(), QTreeView::keyPressEvent(), QCalendarWidget::keyPressEvent(), QTabWidget::keyPressEvent(), QWebView::keyPressEvent(), QAbstractSpinBox::keyPressEvent(), QLabel::keyPressEvent(), QAbstractSlider::keyPressEvent(), QAbstractButton::keyPressEvent(), QTextBrowser::keyPressEvent(), QAbstractScrollArea::keyPressEvent(), QDialog::keyPressEvent(), QMenuBar::keyPressEvent(), QPushButton::keyPressEvent(), QKeySequenceEdit::keyPressEvent()
|
protectedvirtual |
The event handler for the given event can be reimplemented in a subclass to receive key release events for the widget. A widget must call setFocusPolicy() to accept focus initially and have focus in order to receive a key release event.
If you reimplement this handler it is very important to call the base class implementation if you do not act upon the key. A QKeyEvent starts with isAccepted() set to true so you do not need to call QKeyEvent::accept(). Do not call the base class implementation if you consume the key event.
The default implementation closes popup widgets if the user presses Esc. Otherwise the event is ignored and the widget's parent can react to it.
Reimplemented in QTextEdit::keyReleaseEvent(), QGraphicsView::keyReleaseEvent(), QComboBox::keyReleaseEvent(), QPlainTextEdit::keyReleaseEvent(), QWebView::keyReleaseEvent(), QAbstractSpinBox::keyReleaseEvent(), QAbstractButton::keyReleaseEvent(), QKeySequenceEdit::keyReleaseEvent()
QLayout * QWidget::layout | ( | ) | const |
Returns the layout manager that is installed on this widget or a nullptr if no layout manager is installed.
The layout manager sets the geometry of the widget's children that have been added to the layout.
Qt::LayoutDirection QWidget::layoutDirection | ( | ) | const |
Returns the value of the layoutDirection property.
|
protectedvirtual |
This event handler can be reimplemented in a subclass to receive widget leave events which are passed in the event parameter.
A leave event is sent to the widget when the mouse cursor leaves the widget.
Reimplemented in QMdiSubWindow::leaveEvent(), QMenu::leaveEvent(), QToolButton::leaveEvent(), QMenuBar::leaveEvent()
QLocale QWidget::locale | ( | ) | const |
Returns the value of the locale property.
|
slot |
Lowers the widget to the bottom of the parent widget's stack.
After this call the widget will be visually behind (and therefore obscured by) any overlapping sibling widgets.
Translates the widget coordinate pos from the coordinate system of parent to this widget's coordinate system. The parent must not be 0 and must be a parent of the calling widget.
Translates the global screen coordinate pos to widget coordinates.
Translates the parent widget coordinate pos to widget coordinates.
Same as mapFromGlobal() if the widget has no parent.
Translates the widget coordinate pos to the coordinate system of parent. The parent must not be 0 and must be a parent of the calling widget.
Translates the widget coordinate pos to global screen coordinates. For example, mapToGlobal(QPoint(0,0))
would give the global coordinates of the top-left pixel of the widget.
Translates the widget coordinate pos to a coordinate in the parent widget.
Same as mapToGlobal() if the widget has no parent.
QRegion QWidget::mask | ( | ) | const |
Returns the mask currently set on a widget. If no mask is set the return value will be an empty region.
|
inline |
Returns the value of the maximumHeight property.
QSize QWidget::maximumSize | ( | ) | const |
Returns the value of the maximumSize property.
|
inline |
Returns the value of the maximumWidth property.
|
overrideprotectedvirtual |
Internal implementation of the virtual QPaintDevice::metric() method. The value for metric is the metric to get.
Reimplemented from QPaintDevice::metric()
|
inline |
Returns the value of the minimumHeight property.
QSize QWidget::minimumSize | ( | ) | const |
Returns the value of the minimumSize property.
|
virtual |
Returns the value of the minimumSizeHint property.
Reimplemented in QComboBox::minimumSizeHint(), QInputDialog::minimumSizeHint(), QLineEdit::minimumSizeHint(), QTabBar::minimumSizeHint(), QTabWidget::minimumSizeHint(), QAbstractSpinBox::minimumSizeHint(), QCalendarWidget::minimumSizeHint(), QLabel::minimumSizeHint(), QProgressBar::minimumSizeHint(), QMdiArea::minimumSizeHint(), QAbstractScrollArea::minimumSizeHint(), QSplitter::minimumSizeHint(), QMenuBar::minimumSizeHint(), QGroupBox::minimumSizeHint(), QToolButton::minimumSizeHint(), QMdiSubWindow::minimumSizeHint(), QSlider::minimumSizeHint(), QDialog::minimumSizeHint(), QDial::minimumSizeHint(), QCommandLinkButton::minimumSizeHint(), QPushButton::minimumSizeHint(), QCheckBox::minimumSizeHint(), QRadioButton::minimumSizeHint()
|
inline |
Returns the value of the minimumWidth property.
|
protectedvirtual |
The event handler for the given event can be reimplemented in a subclass to receive mouse double click events for the widget. The default implementation generates a normal mouse press event.
Reimplemented in QMdiSubWindow::mouseDoubleClickEvent(), QAbstractItemView::mouseDoubleClickEvent(), QTextEdit::mouseDoubleClickEvent(), QGraphicsView::mouseDoubleClickEvent(), QPlainTextEdit::mouseDoubleClickEvent(), QLineEdit::mouseDoubleClickEvent(), QHeaderView::mouseDoubleClickEvent(), QTreeView::mouseDoubleClickEvent(), QWebView::mouseDoubleClickEvent(), QAbstractScrollArea::mouseDoubleClickEvent()
|
static |
Returns the widget that is currently grabbing the mouse input. If no widget in this application is currently grabbing the mouse a nullptr is returned.
|
protectedvirtual |
This given event can be reimplemented in a subclass to receive mouse move events for the widget. If mouse tracking is switched off, mouse move events only occur if a mouse button is pressed while the mouse is being moved. If mouse tracking is switched on, mouse move events occur even if no mouse button is pressed.
QMouseEvent::pos() reports the position of the mouse cursor, relative to this widget. For press and release events, the position is usually the same as the position of the last mouse move event, but it might be different if the user's hand shakes. This is a feature of the underlying window system, not CopperSpice.
If you want to show a tooltip immediately, while the mouse is moving (e.g., to get the mouse coordinates with QMouseEvent::pos() and show them as a tooltip), you must first enable mouse tracking as described above. Then, to ensure that the tooltip is updated immediately, you must call QToolTip::showText() instead of setToolTip() in your implementation of mouseMoveEvent().
Reimplemented in QMdiSubWindow::mouseMoveEvent(), QAbstractItemView::mouseMoveEvent(), QTextEdit::mouseMoveEvent(), QGraphicsView::mouseMoveEvent(), QPlainTextEdit::mouseMoveEvent(), QLineEdit::mouseMoveEvent(), QHeaderView::mouseMoveEvent(), QMenu::mouseMoveEvent(), QTabBar::mouseMoveEvent(), QTreeView::mouseMoveEvent(), QListView::mouseMoveEvent(), QAbstractSpinBox::mouseMoveEvent(), QWebView::mouseMoveEvent(), QLabel::mouseMoveEvent(), QAbstractButton::mouseMoveEvent(), QSplitterHandle::mouseMoveEvent(), QTextBrowser::mouseMoveEvent(), QAbstractScrollArea::mouseMoveEvent(), QMenuBar::mouseMoveEvent(), QGroupBox::mouseMoveEvent(), QSlider::mouseMoveEvent(), QDial::mouseMoveEvent(), QCheckBox::mouseMoveEvent(), QScrollBar::mouseMoveEvent(), QRadioButton::mouseMoveEvent(), QSizeGrip::mouseMoveEvent()
|
protectedvirtual |
The event handler for the given event can be reimplemented in a subclass to receive mouse press events for the widget.
If you create new widgets in the mousePressEvent() the mouseReleaseEvent() may not end up where you expect, depending on the underlying window system (or X11 window manager), the widgets' location and maybe more.
The default implementation implements the closing of popup widgets when you click outside the window. For other widget types it does nothing.
Reimplemented in QMdiSubWindow::mousePressEvent(), QAbstractItemView::mousePressEvent(), QTextEdit::mousePressEvent(), QGraphicsView::mousePressEvent(), QPlainTextEdit::mousePressEvent(), QComboBox::mousePressEvent(), QLineEdit::mousePressEvent(), QHeaderView::mousePressEvent(), QDateTimeEdit::mousePressEvent(), QMenu::mousePressEvent(), QTabBar::mousePressEvent(), QCalendarWidget::mousePressEvent(), QTreeView::mousePressEvent(), QAbstractSpinBox::mousePressEvent(), QWebView::mousePressEvent(), QLabel::mousePressEvent(), QAbstractButton::mousePressEvent(), QSplitterHandle::mousePressEvent(), QTextBrowser::mousePressEvent(), QToolButton::mousePressEvent(), QMenuBar::mousePressEvent(), QAbstractScrollArea::mousePressEvent(), QGroupBox::mousePressEvent(), QSlider::mousePressEvent(), QDial::mousePressEvent(), QSplashScreen::mousePressEvent(), QScrollBar::mousePressEvent(), QSizeGrip::mousePressEvent()
|
protectedvirtual |
TThis given event can be reimplemented in a subclass to receive mouse release events for the widget.
Reimplemented in QMdiSubWindow::mouseReleaseEvent(), QAbstractItemView::mouseReleaseEvent(), QTextEdit::mouseReleaseEvent(), QGraphicsView::mouseReleaseEvent(), QPlainTextEdit::mouseReleaseEvent(), QComboBox::mouseReleaseEvent(), QLineEdit::mouseReleaseEvent(), QHeaderView::mouseReleaseEvent(), QMenu::mouseReleaseEvent(), QTabBar::mouseReleaseEvent(), QTreeView::mouseReleaseEvent(), QListView::mouseReleaseEvent(), QAbstractSpinBox::mouseReleaseEvent(), QWebView::mouseReleaseEvent(), QLabel::mouseReleaseEvent(), QAbstractButton::mouseReleaseEvent(), QSplitterHandle::mouseReleaseEvent(), QTextBrowser::mouseReleaseEvent(), QToolButton::mouseReleaseEvent(), QAbstractScrollArea::mouseReleaseEvent(), QMenuBar::mouseReleaseEvent(), QGroupBox::mouseReleaseEvent(), QSlider::mouseReleaseEvent(), QDial::mouseReleaseEvent(), QScrollBar::mouseReleaseEvent(), QSizeGrip::mouseReleaseEvent()
void QWidget::move | ( | const QPoint & | point | ) |
Sets the value of the pos property to point.
|
inline |
Sets the value of the pos property to x, y.
|
protectedvirtual |
This event handler can be reimplemented in a subclass to receive widget move events which are passed in the event parameter. When the widget receives this event, it is already at the new position.
The old position is accessible through QMoveEvent::oldPos().
Reimplemented in QMdiSubWindow::moveEvent(), QRubberBand::moveEvent(), QSizeGrip::moveEvent()
|
protectedvirtual |
This special event handler can be reimplemented in a subclass to receive native platform events identified by eventType which are passed in the message parameter.
In your reimplementation of this method, if you want to stop the event being handled by CopperSpice, return true and set result. If you return false this native event is passed back to CopperSpice, which translates the event into a CopperSpice event and sends it to the widget.
This method supersedes the event filter methods x11Event(), winEvent(), and macEvent().
Platform | Event Type Identifier | Message Type | Result Type |
---|---|---|---|
Windows | "windows_generic_MSG" | MSG * | LRESULT |
Reimplemented in QWizard::nativeEvent()
QWidget * QWidget::nativeParentWidget | ( | ) | const |
Returns the native parent for this widget. This is the next ancestor widget that has a system identifier or nullptr if it does not have any native parent.
QWidget * QWidget::nextInFocusChain | ( | ) | const |
Returns the next widget in this widget's focus chain.
QRect QWidget::normalGeometry | ( | ) | const |
Returns the value of the normalGeometry property.
void QWidget::overrideWindowFlags | ( | Qt::WindowFlags | flags | ) |
Sets the window flags for the widget to flags, without telling the window system.
|
overridevirtual |
Returns the widget's paint engine.
This method should not be called explicitly by the user, since it is meant for reimplementation purposes only. The method is called by CopperSpice internally, and the default implementation may not always return a valid pointer.
Implements QPaintDevice::paintEngine()
Reimplemented in QGLWidget::paintEngine()
|
protectedvirtual |
This event handler can be reimplemented in a subclass to receive paint events passed in event. A paint event is a request to repaint all or part of a widget. It can happen for one of the following reasons.
Many widgets can simply repaint their entire surface when asked to, but some slow widgets need to optimize by painting only the requested region: QPaintEvent::region(). This speed optimization does not change the result, as painting is clipped to that region during event processing. QListView and QTableView do this, for example.
CopperSpice also tries to speed up painting by merging multiple paint events into one. When update() is called several times or the window system sends several paint events, CopperSpice merges these events into one event with a larger region (see QRegion::united()). The repaint() method does not permit this optimization, so we suggest using update() whenever possible.
When the paint event occurs, the update region has normally been erased, so you are painting on the widget's background. The background can be set using setBackgroundRole() and setPalette().
QWidget automatically double-buffers its painting, so there is no need to write double-buffering code in paintEvent() to avoid flicker.
For the X11 platform it is possible to toggle global double buffering by calling qt_x11_set_global_double_buffer()
.
Generally you should refrain from calling update() or repaint() inside a paintEvent(). For example, calling update() or repaint() on children inside a paintevent() results in undefined behavior; the child may or may not get a paint event.
Reimplemented in QMdiArea::paintEvent(), QMdiSubWindow::paintEvent(), QAbstractButton::paintEvent(), QGLWidget::paintEvent(), QTextEdit::paintEvent(), QGraphicsView::paintEvent(), QPlainTextEdit::paintEvent(), QComboBox::paintEvent(), QLineEdit::paintEvent(), QMenu::paintEvent(), QHeaderView::paintEvent(), QDateTimeEdit::paintEvent(), QListView::paintEvent(), QTabBar::paintEvent(), QWizard::paintEvent(), QTreeView::paintEvent(), QTabWidget::paintEvent(), QToolBar::paintEvent(), QAbstractSpinBox::paintEvent(), QTableView::paintEvent(), QLabel::paintEvent(), QWebView::paintEvent(), QSplitterHandle::paintEvent(), QLCDNumber::paintEvent(), QProgressBar::paintEvent(), QTextBrowser::paintEvent(), QDockWidget::paintEvent(), QFrame::paintEvent(), QToolButton::paintEvent(), QMenuBar::paintEvent(), QAbstractScrollArea::paintEvent(), QGroupBox::paintEvent(), QOpenGLWidget::paintEvent(), QSlider::paintEvent(), QDial::paintEvent(), QPushButton::paintEvent(), QStatusBar::paintEvent(), QRubberBand::paintEvent(), QCheckBox::paintEvent(), QSvgWidget::paintEvent(), QCommandLinkButton::paintEvent(), QScrollBar::paintEvent(), QFocusFrame::paintEvent(), QRadioButton::paintEvent(), QSizeGrip::paintEvent()
const QPalette & QWidget::palette | ( | ) | const |
Returns the value of the palette property.
|
inline |
Returns the parent of this widget or nullptr if it does not have any parent widget.
QPoint QWidget::pos | ( | ) | const |
Returns the value of the pos property.
QWidget * QWidget::previousInFocusChain | ( | ) | const |
Returns the previous widget in this widget's focus chain.
|
slot |
Raises this widget to the top of the parent widget's stack. After this call the widget will be visually in front of any overlapping sibling widgets.
When using activateWindow() you can call this method to ensure that the window is stacked on top.
|
inline |
Returns the value of the rect property.
void QWidget::releaseKeyboard | ( | ) |
Releases the keyboard grab.
void QWidget::releaseMouse | ( | ) |
Releases the mouse grab.
void QWidget::releaseShortcut | ( | int | id | ) |
Removes the shortcut with the given id from the CopperSpice 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).
void QWidget::removeAction | ( | QAction * | action | ) |
Removes the given action from this widget's list of actions.
void QWidget::render | ( | QPaintDevice * | target, |
const QPoint & | targetOffset = QPoint() , |
||
const QRegion & | sourceRegion = QRegion() , |
||
RenderFlags | renderFlags = RenderFlags(DrawWindowBackground | DrawChildren) |
||
) |
Renders the sourceRegion of this widget into the target using renderFlags to determine how to render. Rendering starts at targetOffset in the target.
If sourceRegion is a null region this method will use QWidget::rect() as the region. Ensure that you call QPainter::end() for the target device's active painter (if any) before rendering.
void QWidget::render | ( | QPainter * | painter, |
const QPoint & | targetOffset = QPoint() , |
||
const QRegion & | sourceRegion = QRegion() , |
||
RenderFlags | renderFlags = RenderFlags(DrawWindowBackground | DrawChildren) |
||
) |
Renders the widget into the painter's QPainter::device(). Transformations and settings applied to the painter will be used when rendering.
|
slot |
Repaints the widget directly by calling paintEvent() immediately, unless updates are disabled or the widget is hidden. We suggest only using repaint() if you need an immediate repaint, for example during animation. In almost all circumstances update() is better, as it permits CopperSpice to optimize for speed and minimize flicker.
void QWidget::repaint | ( | const QRect & | rect | ) |
This method repaints the given rectangle rect inside the widget.
void QWidget::repaint | ( | const QRegion & | region | ) |
This method repaints the given region inside the widget.
void QWidget::repaint | ( | int | x, |
int | y, | ||
int | w, | ||
int | h | ||
) |
void QWidget::resize | ( | const QSize & | size | ) |
Returns the value of the size property.
|
inline |
Sets the value of the size property to w, h.
|
protectedvirtual |
This event handler can be reimplemented in a subclass to receive widget resize events which are passed in the event parameter. When resizeEvent() is called, the widget already has its new geometry. The old size is accessible through QResizeEvent::oldSize().
The widget will be erased and receive a paint event immediately after processing the resize event. No drawing need be (or should be) done inside this handler.
Reimplemented in QMdiArea::resizeEvent(), QMdiSubWindow::resizeEvent(), QAbstractItemView::resizeEvent(), QGLWidget::resizeEvent(), QTextEdit::resizeEvent(), QGraphicsView::resizeEvent(), QPlainTextEdit::resizeEvent(), QComboBox::resizeEvent(), QMessageBox::resizeEvent(), QTabBar::resizeEvent(), QListView::resizeEvent(), QCalendarWidget::resizeEvent(), QWizard::resizeEvent(), QTabWidget::resizeEvent(), QAbstractSpinBox::resizeEvent(), QWebView::resizeEvent(), QSplitterHandle::resizeEvent(), QMenuBar::resizeEvent(), QSplitter::resizeEvent(), QDialog::resizeEvent(), QAbstractScrollArea::resizeEvent(), QGroupBox::resizeEvent(), QDesktopWidget::resizeEvent(), QOpenGLWidget::resizeEvent(), QColumnView::resizeEvent(), QDial::resizeEvent(), QScrollArea::resizeEvent(), QStatusBar::resizeEvent(), QRubberBand::resizeEvent(), QWebInspector::resizeEvent()
bool QWidget::restoreGeometry | ( | const QByteArray & | geometry | ) |
Restores the geometry and state top-level widgets stored in the byte array geometry. Returns true on success, otherwise returns false.
If the restored geometry is off-screen, it will be modified to be inside the available screen geometry.
To restore geometry saved using QSettings, you can use code like this:
Refer to Window Geometry documentation for an overview of geometry issues with windows.
Use QMainWindow::restoreState() to restore the geometry and the state of toolbars and dock widgets.
QByteArray QWidget::saveGeometry | ( | ) | const |
Saves the current geometry and state for top-level widgets. To save the geometry when the window closes, you can implement a close event as shown below.
Use QMainWindow::saveState() to save the geometry and the state of toolbars and dock widgets.
Refer to Window Geometry documentation for an overview of geometry issues with windows.
void QWidget::scroll | ( | int | dx, |
int | dy | ||
) |
Scrolls the widget including its children dx pixels to the right and dy downward. Both dx and dy may be negative.
After scrolling, the widgets will receive paint events for the areas that need to be repainted. For widgets that CopperSpice knows to be opaque, this is only the newly exposed parts. For example, if an opaque widget is scrolled 8 pixels to the left, only an 8-pixel wide stripe at the right edge needs updating.
Since widgets propagate the contents of their parents by default, you need to set the autoFillBackground property, or use setAttribute() to set the Qt::WA_OpaquePaintEvent attribute, to make a widget opaque.
For widgets that use contents propagation, a scroll will cause an update of the entire scroll area.
void QWidget::scroll | ( | int | dx, |
int | dy, | ||
const QRect & | rect | ||
) |
This method only scrolls rect and does not move the children of the widget. If rect is empty or invalid the result is undefined.
void QWidget::setAcceptDrops | ( | bool | on | ) |
Sets the value of the acceptDrops property to on.
void QWidget::setAccessibleDescription | ( | const QString & | description | ) |
Sets the value of the accessibleDescription property to description.
void QWidget::setAccessibleName | ( | const QString & | name | ) |
Sets the value of the accessibleName property to name.
void QWidget::setAttribute | ( | Qt::WidgetAttribute | attribute, |
bool | enable = true |
||
) |
Sets the attribute on this widget if enable is true, otherwise clears the attribute.
void QWidget::setAutoFillBackground | ( | bool | enable | ) |
Sets the value of the autoFillBackground property to enable.
void QWidget::setBackgroundRole | ( | QPalette::ColorRole | role | ) |
Sets the background role of the widget to role. The background role defines the brush from the widget's palette that is used to render the background. If role is QPalette::NoRole, then the widget inherits its parent's background role.
Styles are free to choose any color from the palette. You can modify the palette or set a style sheet if you do not achieve the result you want with setBackgroundRole().
|
inline |
Sets the value of the baseSize property to size.
void QWidget::setBaseSize | ( | int | basew, |
int | baseh | ||
) |
This method is equivalent to calling setBaseSize(QSize(basew, baseh)).
void QWidget::setContentsMargins | ( | const QMargins & | margins | ) |
This method sets the margins around the widget's contents.
Sets the margins around the contents of the widget to have the sizes determined by margins. The margins are used by the layout system, and may be used by subclasses to specify the area to draw in (e.g. excluding the frame).
Changing the margins will trigger a resizeEvent().
void QWidget::setContentsMargins | ( | int | left, |
int | top, | ||
int | right, | ||
int | bottom | ||
) |
Sets the margins around the contents of the widget to have the sizes left, top, right, and bottom. The margins are used by the layout system, and may be used by subclasses to specify the area to draw in (e.g. excluding the frame).
Changing the margins will trigger a resizeEvent().
void QWidget::setContextMenuPolicy | ( | Qt::ContextMenuPolicy | policy | ) |
Sets the value of the contextMenuPolicy property to policy.
void QWidget::setCursor | ( | const QCursor & | cursor | ) |
Sets the value of the cursor property to cursor.
|
slot |
Disables widget input events if disable is true, otherwise enables input events.
void QWidget::setEditFocus | ( | bool | enable | ) |
If enable is true, make this widget have edit focus, in which case Qt::Key_Up and Qt::Key_Down will be delivered to the widget normally, otherwise, Qt::Key_Up and Qt::Key_Down are used to change focus.
|
slot |
Sets the value of the enabled property to enable.
void QWidget::setFixedHeight | ( | int | h | ) |
Sets both the minimum and maximum heights of the widget to h without changing the widths. Provided for convenience.
void QWidget::setFixedSize | ( | const QSize & | size | ) |
Sets both the minimum and maximum sizes of the widget to size, thereby preventing it from ever growing or shrinking. This will override the default size constraints set by QLayout. To remove constraints, set the size to QWIDGETSIZE_MAX.
Alternatively, if you want the widget to have a fixed size based on its contents, you can call QLayout::setSizeConstraint(QLayout::SetFixedSize);
void QWidget::setFixedSize | ( | int | w, |
int | h | ||
) |
Sets the width of the widget to w and the height to h.
void QWidget::setFixedWidth | ( | int | w | ) |
Sets both the minimum and maximum width of the widget to w without changing the heights. Provided for convenience.
|
slot |
Gives the keyboard input focus to this widget (or its focus proxy) if this widget or one of its parents is the active window.
void QWidget::setFocus | ( | Qt::FocusReason | reason | ) |
Gives the keyboard input focus to this widget (or its focus proxy) if this widget or one of its parents is the active window. The reason will be passed as part of any focus event sent from this method. It should give an explanation of what caused the widget to fain focus. If the window is not active the widget will be given focus when the window becomes active.
The following is what will happen when this method is invoked. Nothing actually happens if the focus in and focus out widgets are the same. If the widget is hidden it will not accept focus until it is shown.
On embedded platforms this method will not cause an input panel to be opened by the input method. If this needs to occur send an QEvent::RequestSoftwareInputPanel event to the widget yourself.
This method gives focus to a widget regardless of its focus policy, however it does not clear any keyboard grabs. Refer to grabKeyboard() for more information.
If you call setFocus() in a method which may itself be called from focusOutEvent() or focusInEvent() you may get an infinite recursion.
void QWidget::setFocusPolicy | ( | Qt::FocusPolicy | policy | ) |
Sets the value of the focusPolicy property to policy.
void QWidget::setFocusProxy | ( | QWidget * | widget | ) |
Sets the widget's focus proxy to widget. If widget is a nullptr this method resets this QWidget to have no focus proxy.
Some widgets can "have focus" but create a child widget, such as QLineEdit, to actually handle the focus. In this case, the widget can set the line edit to be its focus proxy. This method setFocusProxy() sets the widget which will actually get focus when "this widget" gets it. If there is a focus proxy, setFocus() and hasFocus() operate on the focus proxy.
void QWidget::setFont | ( | const QFont & | font | ) |
Sets the value of the font property to font.
void QWidget::setForegroundRole | ( | QPalette::ColorRole | role | ) |
Sets the foreground role of the widget to role. The foreground role defines the color from the widget's palette that is used to draw the foreground.
If role is QPalette::NoRole, the widget uses a foreground role that contrasts with the background role.
Styles are free to choose any color from the palette. You can modify the palette or set a style sheet if you do not achieve the result you want with setForegroundRole().
void QWidget::setGeometry | ( | const QRect & | rect | ) |
Sets the value of the geometry property to rect.
|
inline |
Sets the value of the geometry property to the rectangle x, y, w, h.
void QWidget::setGraphicsEffect | ( | QGraphicsEffect * | effect | ) |
The setGraphicsEffect method is used to set the widget's graphics effect. Sets effect as the widget's effect. If there already is an effect installed on this widget, QWidget will delete the existing effect before installing the new effect.
If effect is currently installed on a different widget, setGraphicsEffect() will remove the effect from the widget and install it on this widget. QWidget takes ownership of the effect. This method will apply the effect on itself and all its children. Graphics effects are not supported on Mac, so they will not cause any difference to the rendering of the widget.
|
slot |
Equivalent to calling setVisible(! hidden).
void QWidget::setInputMethodHints | ( | Qt::InputMethodHints | hints | ) |
Sets the value of the property to hints.
void QWidget::setLayout | ( | QLayout * | layout | ) |
Sets the layout manager for this widget to layout. If there already is a layout manager installed on this widget, QWidget will not let you install another. You must first delete the existing layout manager (returned by layout()) before you can call setLayout() with the new layout.
If layout is the layout manager on a different widget, setLayout() will reparent the layout and make it the layout manager for this widget.
An alternative to calling this method is to pass this widget to the layout's constructor. The QWidget will take ownership of layout.
void QWidget::setLayoutDirection | ( | Qt::LayoutDirection | direction | ) |
Sets the value of the layoutDirection property to direction.
void QWidget::setLocale | ( | const QLocale & | locale | ) |
Sets the value of the locale property to locale.
void QWidget::setMask | ( | const QBitmap & | bitmap | ) |
Causes only the pixels of the widget for which bitmap has a corresponding 1 bit to be visible. If the region includes pixels outside the rect() of the widget, window system controls in that area may or may not be visible, depending on the platform. This effect can be slow if the region is particularly complex.
The following code shows how an image with an alpha channel can be used to generate a mask for a widget. The label shown by this code is masked using the image it contains, giving the appearance that an irregularly-shaped image is being drawn directly onto the screen. Masked widgets receive mouse events only on their visible portions.
void QWidget::setMask | ( | const QRegion & | region | ) |
Causes only the parts of the widget which overlap region to be visible. If the region includes pixels outside the rect() of the widget, window system controls in that area may or may not be visible, depending on the platform. This effect can be slow if the region is particularly complex.
void QWidget::setMaximumHeight | ( | int | maxh | ) |
Sets the value of the maximumHeight property to maxh.
|
inline |
Sets the value of the maximumSize property to size.
void QWidget::setMaximumSize | ( | int | maxw, |
int | maxh | ||
) |
This method is equivalent to calling setMaximumSize(QSize(maxw, maxh)).
void QWidget::setMaximumWidth | ( | int | maxw | ) |
Sets the value of the maximumWidth property to maxw.
void QWidget::setMinimumHeight | ( | int | minh | ) |
Sets the value of the minimumHeight property to minh.
|
inline |
Sets the value of the minimumSize property to size.
void QWidget::setMinimumSize | ( | int | minw, |
int | minh | ||
) |
This method is equivalent to calling setMinimumSize(QSize(minw, minh)).
void QWidget::setMinimumWidth | ( | int | minw | ) |
Sets the value of the minimumWidth property to minw.
|
inline |
Sets the value of the mouseTracking property to enable.
void QWidget::setPalette | ( | const QPalette & | palette | ) |
Sets the value of the palette property to palette.
void QWidget::setParent | ( | QWidget * | parent | ) |
Sets the parent of the widget to parent and resets the window flags. The widget is moved to position (0, 0) in its new parent. If the new parent widget is the same as the old parent widget this method does nothing.
If the new parent widget is in a different window, the reparented widget and its children are appended to the end of the tab chain of the new parent widget, in the same internal order as before. If one of the moved widgets had keyboard focus, setParent() calls clearFocus() for that widget.
If the new parent widget is in the same window as the old parent, setting the parent does not change the tab order or keyboard focus.
The widget becomes invisible as part of changing its parent, even if it was previously visible. You must call show() to make the widget visible again.
void QWidget::setParent | ( | QWidget * | parent, |
Qt::WindowFlags | flags | ||
) |
Sets the parent of the widget to parent and then apply the given the window flags.
void QWidget::setShortcutAutoRepeat | ( | int | id, |
bool | enable = true |
||
) |
If enable is true, auto repeat of the shortcut with the given id is enabled, otherwise it is disabled.
void QWidget::setShortcutEnabled | ( | int | id, |
bool | enable = true |
||
) |
If enable is true the shortcut with the given id is enabled, otherwise the shortcut is disabled.
|
inline |
Sets the value of the sizeIncrement property to size.
void QWidget::setSizeIncrement | ( | int | w, |
int | h | ||
) |
Sets the x (width) size increment to w and the y (height) size increment to h.
void QWidget::setSizePolicy | ( | QSizePolicy | policy | ) |
Sets the value of the property to policy
|
inline |
Sets the value of the sizePolicy property to horizontal, vertical.
void QWidget::setStatusTip | ( | const QString & | data | ) |
Sets the value of the statusTip property to data.
void QWidget::setStyle | ( | QStyle * | style | ) |
Sets the widget's GUI style to style. The ownership of the style object is not transferred. If no style is set, the widget uses the application's style, QApplication::style() instead. Setting a widget's style has no effect on existing or future child widgets.
CopperSpice style sheets are currently not supported for custom QStyle subclasses.
|
slot |
Sets the value of the styleSheet property to styleSheet.
|
static |
Puts the second widget after the first widget in the focus order. If first or second has a focus proxy, setTabOrder() correctly substitutes the proxy. Since the tab order of the second widget has changed use code like the following to set a focus chain.
The following code will not produce the desired result.
void QWidget::setToolTip | ( | const QString & | data | ) |
Sets the value of the toolTip property to data.
void QWidget::setToolTipDuration | ( | int | msec | ) |
Sets the value of the statusTip property to msec.
void QWidget::setUpdatesEnabled | ( | bool | enable | ) |
Sets the value of the updatesEnabled property to enable.
|
slot |
Sets the value of the visible property to visible.
void QWidget::setWhatsThis | ( | const QString & | str | ) |
Sets the value of the whatsThis property to str.
void QWidget::setWindowFilePath | ( | const QString & | filePath | ) |
Sets the value of the windowFilePath property to filePath.
void QWidget::setWindowFlags | ( | Qt::WindowFlags | flags | ) |
Sets the value of the windowFlags property to flags.
void QWidget::setWindowIcon | ( | const QIcon & | icon | ) |
Sets the value of the windowIcon property to icon.
void QWidget::setWindowModality | ( | Qt::WindowModality | windowModality | ) |
Sets the value of the windowModality property to windowModality.
|
slot |
Sets the value of the windowModified property to modified.
void QWidget::setWindowOpacity | ( | qreal | level | ) |
Sets the value of the windowOpacity property to level.
void QWidget::setWindowRole | ( | const QString & | role | ) |
Sets the window's role to role. This only makes sense for windows on X11.
void QWidget::setWindowState | ( | Qt::WindowStates | windowState | ) |
Sets the window state to windowState. The window state is a OR'ed combination of Qt::WindowState, Qt::WindowMinimized, Qt::WindowMaximized, Qt::WindowFullScreen, and Qt::WindowActive.
If the window is not visible (i.e. isVisible() returns false), the window state will take effect when show() is called. For visible windows, the change is immediate. For example, to toggle between full-screen and normal mode, use the following code.
In order to restore and activate a minimized window, while preserving its maximized and/or full-screen state, use code similar to the following.
Calling this method will hide the widget. You must call show() to make the widget visible again. On some window systems Qt::WindowActive is not immediate and may be ignored in certain cases. When the window state changes, the widget receives a changeEvent() of type QEvent::WindowStateChange.
|
slot |
Sets the value of the windowTitle property to title.
|
slot |
Shows the widget and its child widgets. This method is equivalent to calling setVisible(true).
|
protectedvirtual |
This event handler can be reimplemented in a subclass to receive widget show events which are passed in the event parameter. Non-spontaneous show events are sent to widgets immediately before they are shown. The spontaneous show events of windows are delivered afterwards.
A widget receives spontaneous show and hide events when its mapping status is changed by the window system, e.g. a spontaneous hide event when the user minimizes the window, and a spontaneous show event when the window is restored again. After receiving a spontaneous hide event, a widget is still considered visible in the sense of isVisible().
Reimplemented in QMdiArea::showEvent(), QMdiSubWindow::showEvent(), QTextEdit::showEvent(), QGraphicsView::showEvent(), QPlainTextEdit::showEvent(), QComboBox::showEvent(), QMessageBox::showEvent(), QTabBar::showEvent(), QTabWidget::showEvent(), QAbstractSpinBox::showEvent(), QProgressDialog::showEvent(), QDialog::showEvent(), QToolBox::showEvent(), QStatusBar::showEvent(), QRubberBand::showEvent(), QSizeGrip::showEvent(), QWebInspector::showEvent()
|
slot |
Shows the widget in full-screen mode. Calling this method only affects windows. To return from full-screen mode call showNormal().
Full-screen mode works fine under Windows, but has certain problems under X. These problems are due to limitations of the ICCCM protocol that specifies the communication between X11 clients and the window manager. ICCCM simply does not understand the concept of non-decorated full-screen windows. Therefore, the best we can do is to request a borderless window and place and resize it to fill the entire screen. Depending on the window manager, this may or may not work. The borderless window is requested using MOTIF hints, which are at least partially supported by virtually all modern window managers.
An alternative would be to bypass the window manager entirely and create a window with the Qt::X11BypassWindowManagerHint flag. This has other severe problems though, like totally broken keyboard focus and very strange effects on desktop changes or when the user raises other windows.
X11 window managers that follow modern post-ICCCM specifications support full-screen mode properly.
|
slot |
Shows the widget maximized.
On X11, this method may not work properly with certain window managers. Refer to Window Geometry documentation for an explanation.
|
slot |
Shows the widget minimized as an icon.
|
slot |
Restores the widget after it has been maximized or minimized.
Calling this function only affects windows.
|
inline |
Returns the value of the size property.
|
virtual |
Returns the value of the sizeHint property.
Reimplemented in QComboBox::sizeHint(), QDateTimeEdit::sizeHint(), QMenu::sizeHint(), QWizard::sizeHint(), QInputDialog::sizeHint(), QLineEdit::sizeHint(), QTabBar::sizeHint(), QGraphicsView::sizeHint(), QSplitterHandle::sizeHint(), QTabWidget::sizeHint(), QAbstractSpinBox::sizeHint(), QCalendarWidget::sizeHint(), QLabel::sizeHint(), QLCDNumber::sizeHint(), QWebView::sizeHint(), QProgressBar::sizeHint(), QMdiArea::sizeHint(), QHeaderView::sizeHint(), QAbstractScrollArea::sizeHint(), QProgressDialog::sizeHint(), QSplitter::sizeHint(), QFontComboBox::sizeHint(), QMenuBar::sizeHint(), QToolButton::sizeHint(), QFrame::sizeHint(), QMdiSubWindow::sizeHint(), QSlider::sizeHint(), QDialog::sizeHint(), QDial::sizeHint(), QScrollArea::sizeHint(), QCommandLinkButton::sizeHint(), QPushButton::sizeHint(), QColumnView::sizeHint(), QSvgWidget::sizeHint(), QCheckBox::sizeHint(), QScrollBar::sizeHint(), QMacNativeWidget::sizeHint(), QRadioButton::sizeHint(), QSizeGrip::sizeHint(), QWebInspector::sizeHint()
QSize QWidget::sizeIncrement | ( | ) | const |
Returns the value of the sizeIncrement property.
QSizePolicy QWidget::sizePolicy | ( | ) | const |
Returns the value of the sizePolicy property.
void QWidget::stackUnder | ( | QWidget * | widget | ) |
QString QWidget::statusTip | ( | ) | const |
Returns the value of the statusTip property.
QStyle * QWidget::style | ( | ) | const |
QString QWidget::styleSheet | ( | ) | const |
Returns the value of the styleSheet property.
|
protectedvirtual |
This given event can be reimplemented in a subclass to receive tablet events for the widget. If you reimplement this handler, it is very important that you ignore() the event if you do not handle it, so that the widget's parent can interpret it. The default implementation ignores the event.
|
inline |
Returns true if attribute is set on this widget, otherwise returns false.
QString QWidget::toolTip | ( | ) | const |
Returns the value of the toolTip property.
int QWidget::toolTipDuration | ( | ) | const |
Returns the value of the toolTipDuration property.
|
inlinedeprecated |
|
inline |
Returns true if the widget is under the mouse cursor, otherwise returns false. This value is not updated properly during drag and drop operations.
void QWidget::ungrabGesture | ( | Qt::GestureType | gestureType | ) |
Unsubscribes the widget from a given gestureType type
void QWidget::unsetCursor | ( | ) |
Sets the value of the cursor property to the default value.
void QWidget::unsetLayoutDirection | ( | ) |
Sets the value of the layoutDirection property to the default value.
void QWidget::unsetLocale | ( | ) |
Sets the value of the locale property to the default value.
|
slot |
Updates the widget unless updates are disabled or the widget is hidden.
This function does not cause an immediate repaint, instead it schedules a paint event for processing when CopperSpice returns to the main event loop. This permits CopperSpice to optimize for more speed and less flicker than a call to repaint() does.
Calling update() several times normally results in just one paintEvent() call.
CopperSpice normally erases the widget's area before the paintEvent() call. If the Qt::WA_OpaquePaintEvent widget attribute is set, the widget is responsible for painting all its pixels with an opaque color.
void QWidget::update | ( | const QRect & | rect | ) |
This method updates a rectangle rect inside the widget.
void QWidget::update | ( | const QRegion & | region | ) |
This method repaints the given region inside the widget.
|
inline |
This method updates a rectangle (x, y, w, h) inside the widget.
void QWidget::updateGeometry | ( | ) |
Notifies the layout system that this widget has changed and may need to change geometry. Call this method if either the sizeHint() or sizePolicy() have changed.
For explicitly hidden widgets, updateGeometry() is a no-op. The layout system will be notified as soon as the widget is shown.
|
protectedslot |
Updates the widget's micro focus.
|
inline |
Returns the value of the updatesEnabled property.
QRegion QWidget::visibleRegion | ( | ) | const |
Returns the unobscured region where paint events can occur. For visible widgets, this is an approximation of the area not covered by other widgets, otherwise this is an empty region.
The repaint() method calls this method if necessary, so in general you do not need to call it.
QString QWidget::whatsThis | ( | ) | const |
Returns the value of the whatsThis property.
|
protectedvirtual |
The event handler for the given event can be reimplemented in a subclass to receive wheel events for the widget. If you reimplement this handler, it is very important that you ignore() the event if you do not handle it, so that the widget's parent can interpret it.
The default implementation ignores the event.
Reimplemented in QTextEdit::wheelEvent(), QPlainTextEdit::wheelEvent(), QGraphicsView::wheelEvent(), QComboBox::wheelEvent(), QMenu::wheelEvent(), QTabBar::wheelEvent(), QDateTimeEdit::wheelEvent(), QListView::wheelEvent(), QWebView::wheelEvent(), QAbstractSpinBox::wheelEvent(), QAbstractSlider::wheelEvent(), QAbstractScrollArea::wheelEvent(), QScrollBar::wheelEvent()
|
inline |
Returns the value of the width property.
QWidget * QWidget::window | ( | ) | const |
Returns the window for this widget, i.e. the next ancestor widget that has (or could have) a window-system frame. If the widget is a window, the widget itself is returned.
Typical usage is changing the window title:
QString QWidget::windowFilePath | ( | ) | const |
Returns the value of the windowFilePath property.
|
inline |
Returns the value of the windowFlags property.
QWindow * QWidget::windowHandle | ( | ) | const |
QIcon QWidget::windowIcon | ( | ) | const |
Returns the value of the windowIcon property.
|
signal |
This signal is emitted when the window icon has changed to the given icon.
|
signal |
This signal is emitted when the window icon text has changed to the given iconText.
Qt::WindowModality QWidget::windowModality | ( | ) | const |
Returns the value of the windowModality property.
qreal QWidget::windowOpacity | ( | ) | const |
Returns the value of the windowOpacity property.
QString QWidget::windowRole | ( | ) | const |
Returns the window's role, or an empty string.
Qt::WindowStates QWidget::windowState | ( | ) | const |
Returns the current window state. The window state is a OR'ed combination of Qt::WindowState, Qt::WindowMinimized, Qt::WindowMaximized, Qt::WindowFullScreen, and Qt::WindowActive.
QString QWidget::windowTitle | ( | ) | const |
Returns the value of the windowTitle property.
|
signal |
This signal is emitted when the window title has changed to the given title.
|
inline |
Returns the window type of this widget. This is identical to windowFlags() & Qt::WindowType_Mask.
WId QWidget::winId | ( | ) | const |
Returns the window system identifier of the widget. This method is supported on all platforms however the return value is only useful when calling platform specific functions.
If a widget is non-native (alien) and winId() is invoked on it, that widget will be provided a native handle. This value may change at run time. An event with type QEvent::WinIdChange will be sent to the widget following a change in window system identifier.
On Mac OS X the type returned depends on which framework was used. If CopperSpice is linked with Carbon the {WId} is actually an HIViewRef. If CopperSpice is linked with Cocoa, {WId} is a pointer to an NSView.
int QWidget::x | ( | ) | const |
Returns the value of the x property.
int QWidget::y | ( | ) | const |
Returns the value of the y property.
|
related |
Equivalent to QList<QWidget *>.
|
related |
Platform dependent window identifier.
|
This property holds whether drop events are enabled for this widget. Setting this property to true announces to the system that this widget may be able to accept drop events. By default this property is false.
If the widget is the desktop (windowType() == Qt::Desktop), this may fail if another application is using the desktop, you can call acceptDrops() to test if this occurs.
Properties | Class Methods |
---|---|
read | acceptDrops |
write | setAcceptDrops |
|
This property holds the widget's description as seen by assistive technologies. By default this property contains an empty string.
Properties | Class Methods |
---|---|
read | accessibleDescription |
write | setAccessibleDescription |
|
This property holds the widget's name as seen by assistive technologies. By default this property contains an empty string.
This property is used by accessible clients to identify, find, or announce the widget for accessible clients.
Properties | Class Methods |
---|---|
write | setAccessibleName |
|
This property holds whether the widget background is filled automatically. If enabled this property will cause CopperSpice to fill the background of the widget before invoking the paint event. 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.
This property can not be turned off and set to false if a widget's parent has a static gradient for its background. By default this property is false.
Properties | Class Methods |
---|---|
read | autoFillBackground |
write | setAutoFillBackground |
|
This property holds the base size of the widget. The base size is used to calculate a proper widget size if the widget defines sizeIncrement().
By default, for a newly-created widget, this property contains a size with zero width and height.
Properties | Class Methods |
---|---|
read | baseSize |
write | setBaseSize |
|
This property holds the bounding rectangle of the widget's children. Hidden children are excluded.
By default, for a widget with no children, this property contains a rectangle with zero width and height located at the origin.
Properties | Class Methods |
---|---|
read | childrenRect |
|
This property holds the combined region occupied by the widget's children.
Hidden children are excluded.
By default, for a widget with no children, this property contains an empty region.
Properties | Class Methods |
---|---|
read | childrenRegion |
|
This property holds how the widget shows a context menu.
The default value of this property is Qt::DefaultContextMenu, which means the contextMenuEvent() handler is called. Other values are Qt::NoContextMenu, Qt::PreventContextMenu, Qt::ActionsContextMenu, and Qt::CustomContextMenu. With Qt::CustomContextMenu, the signal customContextMenuRequested() is emitted.
Properties | Class Methods |
---|---|
read | contextMenuPolicy |
write | setContextMenuPolicy |
|
This property holds the cursor shape for this widget. The mouse cursor will assume this shape when it is over this widget. If no cursor has been set, or after a call to unsetCursor(), the parent's cursor is used. By default, this property contains a cursor with the Qt::ArrowCursor shape.
Refer to the list of predefined cursor objects for a range of useful shapes. For example, an editor widget might use an I-beam cursor.
Some underlying window implementations will reset the cursor if it leaves a widget even if the mouse is grabbed. If you want to have a cursor set for all widgets, even when outside the window, consider QApplication::setOverrideCursor().
Properties | Class Methods |
---|---|
read | cursor |
write | setCursor |
reset | unsetCursor |
|
This property holds whether the widget is enabled. In general an enabled widget handles keyboard and mouse event, a disabled widget does not. Disabling a widget implicitly disables all its children. Enabling respectively enables all child widgets unless they have been explicitly disabled.
Some widgets display themselves differently when they are disabled. For example a button might draw its label grayed out. If your widget needs to know when it becomes enabled or disabled, you can use the changeEvent() with type QEvent::EnabledChange.
By default, this property is true.
Properties | Class Methods |
---|---|
read | isEnabled |
write | setEnabled |
|
This property holds whether this widget (or its focus proxy) has the keyboard input focus. By default this property is false.
Properties | Class Methods |
---|---|
read | hasFocus |
|
This property holds the way the widget accepts keyboard focus.
The 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 the widget has a focus proxy then the focus policy will be propagated to it.
Properties | Class Methods |
---|---|
read | focusPolicy |
write | setFocusPolicy |
|
This property holds the font currently set for the widget.
This property describes the widget's requested font. The font is used by the widget's style when rendering standard components, and is available as a means to ensure that custom widgets can maintain consistency with the native platform's look and feel. It is common that different platforms or different styles may define different fonts for an application.
When you assign a new font to a widget, the properties from this font are combined with the widget's default font to form the widget's final font. You can call fontInfo() to get a copy of the widget's final font. The final font is also used to initialize QPainter's font.
The default depends on the system environment. QApplication maintains a system/theme font which serves as a default for all widgets. There may also be special font defaults for certain types of widgets. You can also define default fonts for widgets yourself by passing a custom font and the name of a widget to QApplication::setFont(). Finally, the font is matched against the CopperSpice font database to find the best match.
QWidget propagates explicit font properties from parent to child. If you change a specific property on a font and assign that font to a widget, that property will propagate to all the widget's children, overriding any system defaults for that property. Fonts by default do not propagate to windows (see isWindow()) unless the Qt::WA_WindowPropagation attribute is enabled.
QWidget's font propagation is similar to its palette propagation.
The current style, which is used to render the content of all standard CopperSpice widgets, is free to choose to use the widget font, or in some cases, to ignore it (partially, or completely). In particular, certain styles like GTK style, Mac style, Windows XP, and Vista style, apply special modifications to the widget font to match the platform's native look and feel. Because of this, assigning properties to a widget's font is not guaranteed to change the appearance of the widget. Instead, you may choose to apply a styleSheet.
Properties | Class Methods |
---|---|
read | font |
write | setFont |
|
This property holds geometry of the widget relative to its parent including any window frame. By default this property contains a value that depends on the user's platform and screen geometry.
Refer to Window Geometry documentation for an overview of geometry issues with windows.
Properties | Class Methods |
---|---|
read | frameGeometry |
|
This property holds the size of the widget including any window frame. By default this property contains a value that depends on the user's platform and screen geometry.
Properties | Class Methods |
---|---|
read | frameSize |
|
This property holds whether the widget is shown in full screen mode. By default this property is false.
A widget in full screen mode occupies the whole screen area and does not display window decorations, such as a title bar.
Properties | Class Methods |
---|---|
read | isFullScreen |
|
This property holds the geometry of the widget relative to its parent and excluding the window frame. By default this property contains a value that depends on the user's platform and screen geometry.
When changing the geometry, the widget, if visible, receives a move event (moveEvent()) and/or a resize event (resizeEvent()) immediately. If the widget is not currently visible, it is guaranteed to receive appropriate events before it is shown.
The size component is adjusted if it lies outside the range defined by minimumSize() and maximumSize().
Refer to Window Geometry documentation for an overview of geometry issues with windows.
Properties | Class Methods |
---|---|
read | geometry |
write | setGeometry |
|
This property holds the height of the widget excluding any window frame. By default this property contains a value that depends on the user's platform and screen geometry.
Refer to Window Geometry documentation for an overview of geometry issues with windows.
Properties | Class Methods |
---|---|
read | height |
|
This property holds what input method specific hints the widget has. The default value is Qt::ImhNone.
This is only relevant for input widgets. It is used by the input method to retrieve hints as to how the input method should operate. For example, if the Qt::ImhFormattedNumbersOnly flag is set, the input method may change its visual components to reflect that only numbers can be entered.
Properties | Class Methods |
---|---|
write | setInputMethodHints |
|
This property holds whether this widget's window is the active window. By default this property is false.
The active window is the window that contains the widget that has keyboard focus. The window may still have focus if it has no widgets or none of its widgets accepts keyboard focus. When popup windows are visible, this property is true for both the active window and for the popup.
Properties | Class Methods |
---|---|
read | isActiveWindow |
|
This property holds the layout direction for this widget. By default this property is set to Qt::LeftToRight.
When the layout direction is set on a widget, it will propagate to the widget's children, but not to a child that is a window and not to a child for which setLayoutDirection() has been explicitly called. Also, child widgets added after setLayoutDirection() has been called for the parent do not inherit the parent's layout direction.
This method no longer affects text layout direction.
Properties | Class Methods |
---|---|
read | layoutDirection |
write | setLayoutDirection |
reset | unsetLayoutDirection |
|
This property holds the widget's locale.
As long as no special locale has been set, this is either the parent's locale or (if this widget is a top level widget), the default locale. If the widget displays dates or numbers, these should be formatted using the widget's locale.
Properties | Class Methods |
---|---|
read | locale |
write | setLocale |
reset | unsetLocale |
|
This property holds whether this widget is maximized. By default this property is false.
This property is only relevant for windows.
Properties | Class Methods |
---|---|
read | isMaximized |
|
This property holds the widget's maximum height in pixels. By default this property contains a value of 16777215.
This property corresponds to the height held by the maximumSize property.
QWIDGETSIZE_MAX
macro limits the maximum size of widgets.Properties | Class Methods |
---|---|
read | maximumHeight |
write | setMaximumHeight |
designable | true |
stored | true |
|
This property holds the widget's maximum size in pixels. By default this property contains a size in which both width and height have values of 16777215.
The widget can not be resized to a larger size than the maximum widget size.
QWIDGETSIZE_MAX
macro limits the maximum size of widgets.Properties | Class Methods |
---|---|
read | maximumSize |
write | setMaximumSize |
|
This property holds the widget's maximum width in pixels. By default this property contains a value of 16777215.
This property corresponds to the width held by the maximumSize property.
QWIDGETSIZE_MAX
macro limits the maximum size of widgets.Properties | Class Methods |
---|---|
read | maximumWidth |
write | setMaximumWidth |
designable | true |
stored | true |
|
This property holds whether this widget is minimized (iconified). By default this property is false.
This property is only relevant for windows.
Properties | Class Methods |
---|---|
read | isMinimized |
|
This property holds the widget's minimum height in pixels. By default this property has a value of 0.
This property corresponds to the height held by the minimumSize property.
Properties | Class Methods |
---|---|
read | minimumHeight |
write | setMinimumHeight |
designable | true |
stored | true |
|
This property holds the widget's minimum size. By default this property contains a size with zero width and height.
The widget can not be resized to a smaller size than the minimum widget size. The widget's size is forced to the minimum size if the current size is smaller. The minimum size set by this function will override the minimum size defined by QLayout. In order to unset the minimum size, use a value of QSize(0, 0)
.
Properties | Class Methods |
---|---|
read | minimumSize |
write | setMinimumSize |
|
This property holds the recommended minimum size for the widget.
If the value of this property is an invalid size, no minimum size is recommended.
The default implementation of minimumSizeHint() returns an invalid size if there is no layout for this widget, and returns the layout's minimum size otherwise. Most built-in widgets reimplement minimumSizeHint().
QLayout will never resize a widget to a size smaller than the minimum size hint unless minimumSize() is set or the size policy is set to QSizePolicy::Ignore. If minimumSize() is set, the minimum size hint will be ignored.
Properties | Class Methods |
---|---|
read | minimumSizeHint |
|
This property holds the widget's minimum width in pixels. By default this property has a value of 0.
This property corresponds to the width held by the minimumSize property.
Properties | Class Methods |
---|---|
read | minimumWidth |
write | setMinimumWidth |
designable | true |
stored | true |
|
This property holds whether the widget is a modal widget. By default this property is false.
This property only makes sense for windows. A modal widget prevents widgets in all other windows from getting any input.
Properties | Class Methods |
---|---|
read | isModal |
|
This property holds whether mouse tracking is enabled for the widget.
If mouse tracking is disabled (the default), the widget only receives mouse move events when at least one mouse button is pressed while the mouse is being moved.
If mouse tracking is enabled, the widget receives mouse move events even if no buttons are pressed.
Properties | Class Methods |
---|---|
read | hasMouseTracking |
write | setMouseTracking |
|
This property holds the geometry of the widget as it will appear when shown as a normal (not maximized or full screen) top-level widget. By default this property contains an empty rectangle.
For child widgets this property always holds an empty rectangle.
Properties | Class Methods |
---|---|
read | normalGeometry |
|
This property holds the widget's palette.
This property describes the widget's palette. The palette is used by the widget's style when rendering standard components and is available to ensure custom widgets can maintain consistency with the native platform's look and feel. Different platforms or different styles often have different palettes.
When assigning a new palette to a widget the color roles from this palette are combined with the widget's default palette to form the final palette. The palette entry for the widget's background role is used to fill the widget's background (see QWidget::autoFillBackground), and the foreground role initializes QPainter's pen.
The default depends on the system environment. QApplication maintains a system/theme palette which serves as a default for all widgets. There may also be special palette defaults for certain types of widgets (e.g., on Windows XP and Vista, all classes that derive from QMenuBar have a special default palette). You can also define default palettes for widgets yourself by passing a custom palette and the name of a widget to QApplication::setPalette(). Finally, the style always has the option of polishing the palette when it is assigned.
QWidget propagates explicit palette roles from parent to child. If you assign a brush or color to a specific role on a palette and assign that palette to a widget, that role will propagate to all the widget's children, overriding any system defaults for that role. Palettes by default do not propagate to windows unless the Qt::WA_WindowPropagation attribute is enabled.
QWidget's palette propagation is similar to its font propagation.
The current style, which is used to render the content of all standard CopperSpice widgets, is free to choose colors and brushes from the widget palette, or in some cases, to ignore the palette (partially, or completely). In particular, certain styles like GTK style, Mac style, Windows XP, and Vista style, depend on third party APIs to render the content of widgets, and these styles typically do not follow the palette. Because of this, assigning roles to a widget's palette is not guaranteed to change the appearance of the widget. Instead, you may choose to apply a styleSheet.
Properties | Class Methods |
---|---|
read | palette |
write | setPalette |
|
This property holds the position of the widget within its parent widget. By default this property contains a position that refers to the origin.
If the widget is a window, the position is that of the widget on the desktop, including its frame. When changing the position, the widget, if visible, receives a move event (moveEvent()) immediately. If the widget is not currently visible, it is guaranteed to receive an event before it is shown.
Refer to Window Geometry documentation for an overview of geometry issues with windows.
Properties | Class Methods |
---|---|
read | pos |
write | move |
designable | true |
stored | true |
|
This property holds the internal geometry of the widget excluding any window frame. By default, this property contains a value that depends on the user's platform and screen geometry.
The rect property equals QRect(0, 0, width(), height()).
Refer to Window Geometry documentation for an overview of geometry issues with windows.
Properties | Class Methods |
---|---|
read | rect |
|
This property holds the size of the widget excluding any window frame. By default, this property contains a value that depends on the user's platform and screen geometry.
If the widget is visible when it is being resized, it receives a resize event (resizeEvent()) immediately. If the widget is not currently visible, it is guaranteed to receive an event before it is shown. The size is adjusted if it lies outside the range defined by minimumSize() and maximumSize().
QSize(0, 0)
will cause the widget to not appear on screen. This also applies to windows.Properties | Class Methods |
---|---|
read | size |
write | resize |
designable | true |
stored | true |
|
This property holds the recommended size for the widget. The default implementation of sizeHint() returns an invalid size if there is no layout for this widget, and returns the layout's preferred size otherwise. If the value of this property is an invalid size, no size is recommended.
Properties | Class Methods |
---|---|
read | sizeHint |
|
This property holds the size increment of the widget. By default the size has a zero width and height.
When the user resizes the window the size will move in steps of sizeIncrement().width() pixels horizontally and sizeIncrement.height() pixels vertically. While you can set the size increment for all widgets it only affects top level windows.
Properties | Class Methods |
---|---|
read | sizeIncrement |
write | setSizeIncrement |
|
This property holds the default layout behavior of the widget.
If there is a QLayout that manages this widget's children, the size policy specified by that layout is used. If there is no such QLayout, the result of this function is used.
The default policy is Preferred/Preferred, which means that the widget can be freely resized, but prefers to be the size sizeHint() returns. Button-like widgets set the size policy to specify that they may stretch horizontally, but are fixed vertically. The same applies to lineedit controls (such as QLineEdit, QSpinBox or an editable QComboBox) and other horizontally orientated widgets (such as QProgressBar). QToolButton's are normally square, so they allow growth in both directions. Widgets that support different directions (such as QSlider, QScrollBar or QHeader) specify stretching in the respective direction only. Widgets that can provide scroll bars (usually subclasses of QScrollArea) tend to specify that they can use additional space, and that they can make do with less than sizeHint().
Properties | Class Methods |
---|---|
read | sizePolicy |
write | setSizePolicy |
|
|
This property holds the widget's style sheet. The style sheet contains a textual description of customizations to the widget's style, as described in the CopperSpice Style Sheets document.
CopperSpice style sheets fully support Mac OS X.
Properties | Class Methods |
---|---|
read | styleSheet |
write | setStyleSheet |
|
This property holds the widget's tooltip. By default this property contains an empty string.
By default tooltips are only shown for widgets that are children of the active window. You can change this behavior by setting the attribute Qt::WA_AlwaysShowToolTips on the window, not on the widget with the tooltip.
If you want to control a tooltip's behavior, you can intercept the event() function and catch the QEvent::ToolTip event (e.g., if you want to customize the area for which the tooltip should be shown).
Properties | Class Methods |
---|---|
read | toolTip |
write | setToolTip |
|
This property holds whether updates are enabled. By default this property is true.
An updates enabled widget receives paint events and has a system background; a disabled widget does not. This also implies that calling update() and repaint() has no effect if updates are disabled.
setUpdatesEnabled() is normally used to disable updates for a short period of time, for instance to avoid screen flicker during large changes. In CopperSpice, widgets normally do not generate screen flicker, but on X11 the server might erase regions on the screen when widgets get hidden before they can be replaced by other widgets. Disabling updates solves this.
Disabling a widget implicitly disables all its children. Enabling a widget enables all child widgets except top-level widgets or those that have been explicitly disabled. Re-enabling updates implicitly calls update() on the widget.
Properties | Class Methods |
---|---|
read | updatesEnabled |
write | setUpdatesEnabled |
designable | true |
|
This property holds whether the widget is visible.
Calling setVisible(true) or show() sets the widget to visible status if all its parent widgets up to the window are visible. If an ancestor is not visible, the widget will not become visible until all its ancestors are shown. If its size or position has changed, CopperSpice guarantees that a widget gets move and resize events just before it is shown. If the widget has not been resized yet, CopperSpice will adjust the widget's size to a useful default using adjustSize().
Calling setVisible(false) or hide() hides a widget explicitly. An explicitly hidden widget will never become visible, even if all its ancestors become visible, unless you show it.
A widget receives show and hide events when its visibility status changes. Between a hide and a show event, there is no need to waste CPU cycles preparing or displaying information to the user. A video application, for example, might simply stop generating new frames.
A widget that happens to be obscured by other windows on the screen is considered to be visible. The same applies to iconified windows and windows that exist on another virtual desktop (on platforms that support this concept). A widget receives spontaneous show and hide events when its mapping status is changed by the window system, e.g. a spontaneous hide event when the user minimizes the window, and a spontaneous show event when the window is restored again.
You almost never have to reimplement the setVisible() function. If you need to change some settings before a widget is shown, use showEvent() instead. If you need to do some delayed initialization use the Polish event delivered to the event() function.
Properties | Class Methods |
---|---|
read | isVisible |
write | setVisible |
designable | true |
|
This property holds the widget's What's This help text. By default this property contains an empty string.
Properties | Class Methods |
---|---|
read | whatsThis |
write | setWhatsThis |
|
This property holds the width of the widget excluding any window frame. By default this property contains a value that depends on the user's platform and screen geometry.
Refer to Window Geometry documentation for an overview of geometry issues with windows.
Properties | Class Methods |
---|---|
read | width |
|
This property holds the file path associated with a widget. By default, this property contains an empty string.
This property only makes sense for windows. It associates a file path with a window. If you set the file path, but have not set the window title, CopperSpice sets the window title to contain a string created using the following components.
On Mac OS X:
On Windows and X11:
'*'
character, if the windowModified property is set. 0x2014
unicode character, padded either side by spaces. If the window title is set at any point, then the window title takes precedence and will be shown instead of the file path string. Additionally, on Mac OS X this has an added benefit that it sets the proxy icon for the window, assuming that the file path exists.
If no file path is set this property contains an empty string.
Properties | Class Methods |
---|---|
read | windowFilePath |
write | setWindowFilePath |
|
Window flags are a combination of a type (e.g. Qt::Dialog) and zero or more hints to the window system (e.g. Qt::FramelessWindowHint).
If the widget had type Qt::Widget or Qt::SubWindow and becomes a window (Qt::Window, Qt::Dialog, etc.), it is put at position (0, 0) on the desktop. If the widget is a window and becomes a Qt::Widget or Qt::SubWindow, it is put at position (0, 0) relative to its parent widget.
Properties | Class Methods |
---|---|
read | windowFlags |
write | setWindowFlags |
designable | true |
|
This property holds the widget's icon. This property only makes sense for windows. If no icon has been set, windowIcon() returns the application icon (QApplication::windowIcon()).
Properties | Class Methods |
---|---|
write | setWindowIcon |
notify | windowIconChanged |
|
This property holds the widget's icon text. This property only makes sense for windows. If no icon text has been set, this functions returns an empty string.
Properties | Class Methods |
---|---|
write | setWindowIconText |
notify | windowIconTextChanged |
|
This property holds which windows are blocked by the modal widget. This property only makes sense for windows. By default this property is Qt::NonModal.
A modal widget prevents widgets in other windows from getting input. The value of this property controls which windows are blocked when the widget is visible. Changing this property while the window is visible has no effect; you must hide() the widget first, then show() it again.
Properties | Class Methods |
---|---|
read | windowModality |
write | setWindowModality |
|
This property holds whether the document shown in the window has unsaved changes.
A modified window is a window whose content has changed but has not been saved to disk. This flag will have different effects varied by the platform. On Mac OS X the close button will have a modified look; on other platforms, the window title will have an '*' (asterisk).
The window title must contain a "[*]" placeholder, which indicates where the '*' should appear. Normally, it should appear right after the file name (e.g., "document1.txt[*] - Text Editor"). If the window is not modified, the placeholder is simply removed.
If a widget is set as modified, all its ancestors will also be set as modified. However, if you call setWindowModified(false)
on a widget, this will not propagate to its parent because other children of the parent might have been modified.
Properties | Class Methods |
---|---|
write | setWindowModified |
|
This property holds the level of opacity for the window. The valid range of opacity is from 1.0 (completely opaque) to 0.0 (completely transparent). By default the value of this property is 1.0.
This feature is available on OS X, Windows, and X11 platforms which support the Composite extension. Under X11, the composite manager and the X11 specific _NET_WM_WINDOW_OPACITY atom needs to be supported by the window manager you are using.
Properties | Class Methods |
---|---|
write | setWindowOpacity |
|
This property holds the window title. This property only makes sense for top-level widgets, such as windows and dialogs. If no caption has been set, the title is based of the windowFilePath. If neither of these is set, then the title is an empty string.
If you use the windowModified mechanism, the window title must contain a "[*]" placeholder, which indicates where the '*' should appear. Normally, it should appear right after the file name (e.g., "document1.txt[*] - Text Editor"). If the windowModified property is false (the default), the placeholder is simply removed.
Properties | Class Methods |
---|---|
read | windowTitle |
write | setWindowTitle |
notify | windowTitleChanged |
|
This property holds the x coordinate of the widget relative to its parent including any window frame. By default this property has a value of 0.
Refer to Window Geometry documentation for an overview of geometry issues with windows.
Properties | Class Methods |
---|---|
read | x |
|
This property holds the y coordinate of the widget relative to its parent and including any window frame. By default this property has a value of 0.
Refer to Window Geometry documentation for an overview of geometry issues with windows.
Properties | Class Methods |
---|---|
read | y |