|
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.trolltech.qt.QSignalEmitter
com.trolltech.qt.QtJambiObject
com.trolltech.qt.core.QObject
com.trolltech.qt.gui.QWidget
com.trolltech.qt.gui.QFrame
com.trolltech.qt.gui.QLabel
public class QLabel
The QLabel widget provides a text or image display.
QLabel is used for displaying text or an image. No user interaction functionality is provided. The visual appearance of the label can be configured in various ways, and it can be used for specifying a focus mnemonic key for another widget.
A QLabel can contain any of the following content types:
Content | Setting |
---|---|
Plain text | Pass a QString to setText. |
Rich text | Pass a QString that contains rich text to setText. |
A pixmap | Pass a QPixmap to setPixmap. |
A movie | Pass a QMovie to setMovie. |
A number | Pass an int or a double to setNum, which converts the number to plain text. |
Nothing | The same as an empty plain text. This is the default. Set by clear. |
When the content is changed using any of these functions, any previous content is cleared.
The look of a QLabel can be tuned in several ways. All the settings of QFrame are available for specifying a widget frame. The positioning of the content within the QLabel widget area can be tuned with setAlignment and setIndent. Text content can also wrap lines along word bounderies with setWordWrap. For example, this code sets up a sunken panel with a two-line text in the bottom right corner (both lines being flush with the right side of the label):
QLabel *label = new QLabel(this); label->setFrameStyle(QFrame::Panel | QFrame::Sunken); label->setText("first line\nsecond line"); label->setAlignment(Qt::AlignBottom | Qt::AlignRight);
A QLabel is often used as a label for an interactive widget. For this use QLabel provides a useful mechanism for adding an mnemonic (see QKeysequence) that will set the keyboard focus to the other widget (called the QLabel's "buddy"). For example:
QLineEdit* phoneEdit = new QLineEdit(this); QLabel* phoneLabel = new QLabel("&Phone:", this); phoneLabel->setBuddy(phoneEdit);
In this example, keyboard focus is transferred to the label's buddy (the QLineEdit) when the user presses Alt+P. If the buddy was a button (inheriting from QAbstractButton), triggering the mnemonic would emulate a button click.
![]() | A label shown in the Macintosh widget style. |
![]() | A label shown in the Plastique widget style. |
![]() | A label shown in the Windows XP widget style. |
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.trolltech.qt.gui.QFrame |
---|
QFrame.Shadow, QFrame.Shape, QFrame.StyleMask |
Nested classes/interfaces inherited from class com.trolltech.qt.gui.QWidget |
---|
QWidget.RenderFlag, QWidget.RenderFlags |
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter |
---|
QSignalEmitter.Signal0, QSignalEmitter.Signal1<A>, QSignalEmitter.Signal2<A,B>, QSignalEmitter.Signal3<A,B,C>, QSignalEmitter.Signal4<A,B,C,D>, QSignalEmitter.Signal5<A,B,C,D,E>, QSignalEmitter.Signal6<A,B,C,D,E,F>, QSignalEmitter.Signal7<A,B,C,D,E,F,G>, QSignalEmitter.Signal8<A,B,C,D,E,F,G,H>, QSignalEmitter.Signal9<A,B,C,D,E,F,G,H,I> |
Field Summary | |
---|---|
QSignalEmitter.Signal1<java.lang.String> |
linkActivated
This signal is emitted when the user clicks a link. |
QSignalEmitter.Signal1<java.lang.String> |
linkHovered
This signal is emitted when the user hovers over a link. |
Fields inherited from class com.trolltech.qt.gui.QWidget |
---|
customContextMenuRequested |
Constructor Summary | |
---|---|
QLabel()
Equivalent to QLabel(0, 0). |
|
QLabel(QWidget parent)
Equivalent to QLabel(parent, 0). |
|
QLabel(QWidget parent,
Qt.WindowFlags f)
Constructs an empty label. |
|
QLabel(java.lang.String text)
Equivalent to QLabel(text, 0, 0). |
|
QLabel(java.lang.String text,
QWidget parent)
Equivalent to QLabel(text, parent, 0). |
|
QLabel(java.lang.String text,
QWidget parent,
Qt.WindowFlags f)
Constructs a label that displays the text, text. |
Method Summary | |
---|---|
Qt.Alignment |
alignment()
Returns the alignment of the label's contents. |
QWidget |
buddy()
Returns this label's buddy, or 0 if no buddy is currently set. |
protected void |
changeEvent(QEvent arg__1)
This event handler can be reimplemented to handle state changes. The state being changed in this event can be retrieved through event arg__1. Change events include: QEvent::ToolBarChange, QEvent::ActivationChange, QEvent::EnabledChange, QEvent::FontChange, QEvent::StyleChange, QEvent::PaletteChange, QEvent::WindowTitleChange, QEvent::IconTextChange, QEvent::ModifiedChange, QEvent::MouseTrackingChange, QEvent::ParentChange, QEvent::WindowStateChange, QEvent::LanguageChange, QEvent::LocaleChange, QEvent::LayoutDirectionChange. |
void |
clear()
Clears any label contents. |
protected void |
contextMenuEvent(QContextMenuEvent ev)
This event handler, for event arg__1, can be reimplemented in a subclass to receive widget context menu events. |
boolean |
event(QEvent e)
This is the main event handler; it handles event arg__1. You can reimplement this function 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 function 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. |
protected void |
focusInEvent(QFocusEvent ev)
This event handler can be reimplemented in a subclass to receive keyboard focus events (focus received) for the widget. |
protected boolean |
focusNextPrevChild(boolean next)
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't. |
protected void |
focusOutEvent(QFocusEvent ev)
This event handler can be reimplemented in a subclass to receive keyboard focus events (focus lost) for the widget. |
static QLabel |
fromNativePointer(QNativePointer nativePointer)
This function returns the QLabel instance pointed to by nativePointer |
boolean |
hasScaledContents()
Returns whether the label will scale its contents to fill all available space.. |
int |
heightForWidth(int arg__1)
Returns the preferred height for this widget, given the width arg__1. |
int |
indent()
Returns the label's text indent in pixels. |
protected void |
keyPressEvent(QKeyEvent ev)
This event handler, for event arg__1, can be reimplemented in a subclass to receive key press events for the widget. |
int |
margin()
Returns the width of the margin. |
QSize |
minimumSizeHint()
Returns the recommended minimum size for the widget. |
protected void |
mouseMoveEvent(QMouseEvent ev)
This event handler, for event arg__1, can be reimplemented in a subclass to receive mouse move events for the widget. |
protected void |
mousePressEvent(QMouseEvent ev)
This event handler, for event arg__1, can be reimplemented in a subclass to receive mouse press events for the widget. |
protected void |
mouseReleaseEvent(QMouseEvent ev)
This event handler, for event arg__1, can be reimplemented in a subclass to receive mouse release events for the widget. |
QMovie |
movie()
Returns a pointer to the label's movie, or 0 if no movie has been set. |
boolean |
openExternalLinks()
Specifies whether QLabel should automatically open links using QDesktopServices::openUrl() instead of emitting the anchorClicked() signal. |
protected void |
paintEvent(QPaintEvent arg__1)
This event handler can be reimplemented in a subclass to receive paint events which are passed in the arg__1 parameter. A paint event is a request to repaint all or part of the widget. It can happen as a result of repaint or update, or because the widget was obscured and has now been uncovered, or for many other 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. Qt 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, Qt merges these events into one event with a larger region (see QRegion::united()). repaint 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 that you're painting on the widget's background. The background can be set using setBackgroundRole and setPalette. From Qt 4.0, QWidget automatically double-buffers its painting, so there's no need to write double-buffering code in paintEvent to avoid flicker. Note: Under X11 it is possible to toggle the global double buffering by calling qt_x11_set_global_double_buffer(). Example usage: ... extern void qt_x11_set_global_double_buffer(bool); qt_x11_set_global_double_buffer(false); ... Note: In general, one should refrain from calling update or repaint inside of 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. |
QPicture |
picture()
Returns the label's picture or null if the label doesn't have a picture. |
QPixmap |
pixmap()
Returns the label's pixmap or null if the label doesn't have a picture. |
void |
setAlignment(Qt.Alignment arg__1)
Sets the alignment of the label's contents to arg__1. |
void |
setAlignment(Qt.AlignmentFlag... arg__1)
Sets the alignment of the label's contents to arg__1. |
void |
setBuddy(QWidget arg__1)
Sets this label's buddy to arg__1. |
void |
setIndent(int arg__1)
Sets the label's text indent in pixels to arg__1. |
void |
setMargin(int arg__1)
Sets the width of the margin to arg__1. |
void |
setMovie(QMovie movie)
Sets the label contents to movie. |
void |
setNum(double arg__1)
Sets the label contents to plain text containing the textual representation of double arg__1. |
void |
setNum(int arg__1)
Sets the label contents to plain text containing the textual representation of integer arg__1. |
void |
setOpenExternalLinks(boolean open)
Specifies whether QLabel should automatically open links using QDesktopServices::openUrl() instead of emitting the anchorClicked() signal. |
void |
setPicture(QPicture arg__1)
Sets the label contents to arg__1. |
void |
setPixmap(QPixmap arg__1)
Sets the label's pixmap to arg__1. |
void |
setScaledContents(boolean arg__1)
Sets whether the label will scale its contents to fill all available space. |
void |
setText(java.lang.String arg__1)
Sets the label's text to arg__1. |
void |
setTextFormat(Qt.TextFormat arg__1)
Sets the label's text format to arg__1. |
void |
setTextInteractionFlags(Qt.TextInteractionFlag... flags)
Specifies how the label should interact with user input if it displays text. |
void |
setTextInteractionFlags(Qt.TextInteractionFlags flags)
Specifies how the label should interact with user input if it displays text. |
void |
setWordWrap(boolean on)
Sets the label's word-wrapping policy to on. |
QSize |
sizeHint()
Returns the recommended size for the widget. If the value of this property is an invalid size, no size is recommended. 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. |
java.lang.String |
text()
Returns the label's text. |
Qt.TextFormat |
textFormat()
Returns the label's text format. |
Qt.TextInteractionFlags |
textInteractionFlags()
Specifies how the label should interact with user input if it displays text. |
boolean |
wordWrap()
Returns the label's word-wrapping policy. |
Methods inherited from class com.trolltech.qt.gui.QFrame |
---|
drawFrame, frameRect, frameShadow, frameShape, frameStyle, frameWidth, lineWidth, midLineWidth, setFrameRect, setFrameShadow, setFrameShape, setFrameStyle, setLineWidth, setMidLineWidth |
Methods inherited from class com.trolltech.qt.core.QObject |
---|
blockSignals, childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, property, removeEventFilter, setObjectName, setParent, setProperty, signalsBlocked, startTimer, thread, timerEvent |
Methods inherited from class com.trolltech.qt.QtJambiObject |
---|
dispose, disposed, finalize, reassignNativeResources, tr, tr, tr |
Methods inherited from class com.trolltech.qt.QSignalEmitter |
---|
disconnect, disconnect, signalSender |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.trolltech.qt.QtJambiInterface |
---|
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership |
Field Detail |
---|
public final QSignalEmitter.Signal1<java.lang.String> linkActivated
This signal is emitted when the user clicks a link. The URL referred to by the anchor is passed in link.
public final QSignalEmitter.Signal1<java.lang.String> linkHovered
This signal is emitted when the user hovers over a link. The URL referred to by the anchor is passed in link.
Constructor Detail |
---|
public QLabel(QWidget parent)
Equivalent to QLabel(parent, 0).
public QLabel()
Equivalent to QLabel(0, 0).
public QLabel(QWidget parent, Qt.WindowFlags f)
Constructs an empty label.
The parent and widget flag f, arguments are passed to the QFrame constructor.
public QLabel(java.lang.String text, QWidget parent)
Equivalent to QLabel(text, parent, 0).
public QLabel(java.lang.String text)
Equivalent to QLabel(text, 0, 0).
public QLabel(java.lang.String text, QWidget parent, Qt.WindowFlags f)
Constructs a label that displays the text, text.
The parent and widget flag f, arguments are passed to the QFrame constructor.
Method Detail |
---|
public final Qt.Alignment alignment()
Returns the alignment of the label's contents.
public final QWidget buddy()
Returns this label's buddy, or 0 if no buddy is currently set.
public final void clear()
Clears any label contents.
public final boolean hasScaledContents()
Returns whether the label will scale its contents to fill all available space..
When enabled and the label shows a pixmap, it will scale the pixmap to fill the available space.
This property's default is false.
public final int indent()
Returns the label's text indent in pixels.
If a label displays text, the indent applies to the left edge if alignment is Qt::AlignLeft, to the right edge if alignment is Qt::AlignRight, to the top edge if alignment is Qt::AlignTop, and to to the bottom edge if alignment is Qt::AlignBottom.
If indent is negative, or if no indent has been set, the label computes the effective indent as follows: If frameWidth is 0, the effective indent becomes 0. If frameWidth is greater than 0, the effective indent becomes half the width of the "x" character of the widget's current font.
public final int margin()
Returns the width of the margin.
The margin is the distance between the innermost pixel of the frame and the outermost pixel of contents.
The default margin is 0.
public final QMovie movie()
Returns a pointer to the label's movie, or 0 if no movie has been set.
public final boolean openExternalLinks()
Specifies whether QLabel should automatically open links using QDesktopServices::openUrl() instead of emitting the anchorClicked() signal.
Note: The textInteractionFlags set on the label need to include either LinksAccessibleByMouse or LinksAccessibleByKeyboard.
The default value is false.
public final void setAlignment(Qt.AlignmentFlag... arg__1)
Sets the alignment of the label's contents to arg__1.
public final void setAlignment(Qt.Alignment arg__1)
Sets the alignment of the label's contents to arg__1.
public final void setBuddy(QWidget arg__1)
Sets this label's buddy to arg__1.
When the user presses the shortcut key indicated by this label, the keyboard focus is transferred to the label's buddy widget.
The buddy mechanism is only available for QLabels that contain text in which one character is prefixed with an ampersand, '&'. This character is set as the shortcut key. See the QShortcut documentation for details (to display an actual ampersand, use '&&').
In a dialog, you might create two data entry widgets and a label for each, and set up the geometry layout so each label is just to the left of its data entry widget (its "buddy"), for example:
QLineEdit *nameEd = new QLineEdit(this);
QLabel *nameLb = new QLabel("&Name:", this);
nameLb->setBuddy(nameEd);
QLineEdit *phoneEd = new QLineEdit(this);
QLabel *phoneLb = new QLabel("&Phone:", this);
phoneLb->setBuddy(phoneEd);
// (layout setup not shown)
With the code above, the focus jumps to the Name field when the user presses Alt+N, and to the Phone field when the user presses Alt+P.
To unset a previously set buddy, call this function with arg__1 set to 0.
public final void setIndent(int arg__1)
Sets the label's text indent in pixels to arg__1.
If a label displays text, the indent applies to the left edge if alignment is Qt::AlignLeft, to the right edge if alignment is Qt::AlignRight, to the top edge if alignment is Qt::AlignTop, and to to the bottom edge if alignment is Qt::AlignBottom.
If indent is negative, or if no indent has been set, the label computes the effective indent as follows: If frameWidth is 0, the effective indent becomes 0. If frameWidth is greater than 0, the effective indent becomes half the width of the "x" character of the widget's current font.
public final void setMargin(int arg__1)
Sets the width of the margin to arg__1.
The margin is the distance between the innermost pixel of the frame and the outermost pixel of contents.
The default margin is 0.
public final void setMovie(QMovie movie)
Sets the label contents to movie. Any previous content is cleared. The label does NOT take ownership of the movie.
The buddy shortcut, if any, is disabled.
public final void setNum(double arg__1)
Sets the label contents to plain text containing the textual representation of double arg__1. Any previous content is cleared. Does nothing if the double's string representation is the same as the current contents of the label.
The buddy shortcut, if any, is disabled.
public final void setNum(int arg__1)
Sets the label contents to plain text containing the textual representation of integer arg__1. Any previous content is cleared. Does nothing if the integer's string representation is the same as the current contents of the label.
The buddy shortcut, if any, is disabled.
public final void setOpenExternalLinks(boolean open)
Specifies whether QLabel should automatically open links using QDesktopServices::openUrl() instead of emitting the anchorClicked() signal.
Note: The textInteractionFlags set on the label need to include either LinksAccessibleByMouse or LinksAccessibleByKeyboard.
The default value is false.
public final void setPicture(QPicture arg__1)
Sets the label contents to arg__1. Any previous content is cleared.
The buddy shortcut, if any, is disabled.
public final void setPixmap(QPixmap arg__1)
Sets the label's pixmap to arg__1.
If no pixmap has been set this will return 0.
Setting the pixmap clears any previous content. The buddy shortcut, if any, is disabled.
public final void setScaledContents(boolean arg__1)
Sets whether the label will scale its contents to fill all available space. to arg__1.
When enabled and the label shows a pixmap, it will scale the pixmap to fill the available space.
This property's default is false.
public final void setText(java.lang.String arg__1)
Sets the label's text to arg__1.
If no text has been set this will return an empty string. Setting the text clears any previous content.
The text will be interpreted either as plain text or as rich text, depending on the text format setting; see setTextFormat. The default setting is Qt::AutoText; i.e. QLabel will try to auto-detect the format of the text set.
If a buddy has been set, the buddy mnemonic key is updated from the new text.
Note that QLabel is well-suited to display small rich text documents, such as small documents that get their document specific settings (font, text color, link color) from the label's palette and font properties. For large documents, use QTextEdit in read-only mode instead. QTextEdit can also provide a scroll bar when necessary.
Note: This function enables mouse tracking if text contains rich text.
public final void setTextFormat(Qt.TextFormat arg__1)
Sets the label's text format to arg__1.
See the Qt::TextFormat enum for an explanation of the possible options.
The default format is Qt::AutoText.
public final void setTextInteractionFlags(Qt.TextInteractionFlag... flags)
Specifies how the label should interact with user input if it displays text.
If the flags contain Qt::LinksAccessibleByKeyboard the focus policy is also automatically set to Qt::StrongFocus. If Qt::TextSelectableByKeyboard is set then the focus policy is set to Qt::ClickFocus.
The default value is Qt::LinksAccessibleByMouse.
public final void setTextInteractionFlags(Qt.TextInteractionFlags flags)
Specifies how the label should interact with user input if it displays text.
If the flags contain Qt::LinksAccessibleByKeyboard the focus policy is also automatically set to Qt::StrongFocus. If Qt::TextSelectableByKeyboard is set then the focus policy is set to Qt::ClickFocus.
The default value is Qt::LinksAccessibleByMouse.
public final void setWordWrap(boolean on)
Sets the label's word-wrapping policy to on.
If this property is true then label text is wrapped where necessary at word-breaks; otherwise it is not wrapped at all.
public final java.lang.String text()
Returns the label's text.
If no text has been set this will return an empty string. Setting the text clears any previous content.
The text will be interpreted either as plain text or as rich text, depending on the text format setting; see setTextFormat. The default setting is Qt::AutoText; i.e. QLabel will try to auto-detect the format of the text set.
If a buddy has been set, the buddy mnemonic key is updated from the new text.
Note that QLabel is well-suited to display small rich text documents, such as small documents that get their document specific settings (font, text color, link color) from the label's palette and font properties. For large documents, use QTextEdit in read-only mode instead. QTextEdit can also provide a scroll bar when necessary.
Note: This function enables mouse tracking if text contains rich text.
public final Qt.TextFormat textFormat()
Returns the label's text format.
See the Qt::TextFormat enum for an explanation of the possible options.
The default format is Qt::AutoText.
public final Qt.TextInteractionFlags textInteractionFlags()
Specifies how the label should interact with user input if it displays text.
If the flags contain Qt::LinksAccessibleByKeyboard the focus policy is also automatically set to Qt::StrongFocus. If Qt::TextSelectableByKeyboard is set then the focus policy is set to Qt::ClickFocus.
The default value is Qt::LinksAccessibleByMouse.
public final boolean wordWrap()
Returns the label's word-wrapping policy.
If this property is true then label text is wrapped where necessary at word-breaks; otherwise it is not wrapped at all.
protected void changeEvent(QEvent arg__1)
This event handler can be reimplemented to handle state changes.
The state being changed in this event can be retrieved through event arg__1.
Change events include: QEvent::ToolBarChange, QEvent::ActivationChange, QEvent::EnabledChange, QEvent::FontChange, QEvent::StyleChange, QEvent::PaletteChange, QEvent::WindowTitleChange, QEvent::IconTextChange, QEvent::ModifiedChange, QEvent::MouseTrackingChange, QEvent::ParentChange, QEvent::WindowStateChange, QEvent::LanguageChange, QEvent::LocaleChange, QEvent::LayoutDirectionChange.
changeEvent
in class QFrame
protected void contextMenuEvent(QContextMenuEvent ev)
This event handler, for event arg__1, 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. See the QContextMenuEvent documentation for more details.
contextMenuEvent
in class QWidget
public boolean event(QEvent e)
This is the main event handler; it handles event arg__1. You can reimplement this function 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 function 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.
event
in class QFrame
protected void focusInEvent(QFocusEvent ev)
This event handler can be reimplemented in a subclass to receive keyboard focus events (focus received) for the widget. The event is passed in the arg__1 parameter
A widget normally must setFocusPolicy to something other than Qt::NoFocus in order to receive focus events. (Note that the application programmer can call setFocus on any widget, even those that do not normally accept focus.)
The default implementation updates the widget (except for windows that do not specify a focusPolicy).
focusInEvent
in class QWidget
protected boolean focusNextPrevChild(boolean next)
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't.
If next is true, this function searches forward, if next is false, it searches backward.
Sometimes, you will want to reimplement this function. 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 function for an object, you thus gain control of focus traversal for all child widgets.
focusNextPrevChild
in class QWidget
protected void focusOutEvent(QFocusEvent ev)
This event handler can be reimplemented in a subclass to receive keyboard focus events (focus lost) for the widget. The events is passed in the arg__1 parameter.
A widget normally must setFocusPolicy to something other than Qt::NoFocus in order to receive focus events. (Note that the application programmer can call setFocus on any widget, even those that do not normally accept focus.)
The default implementation updates the widget (except for windows that do not specify a focusPolicy).
focusOutEvent
in class QWidget
public int heightForWidth(int arg__1)
Returns the preferred height for this widget, given the width arg__1.
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.
heightForWidth
in class QWidget
protected void keyPressEvent(QKeyEvent ev)
This event handler, for event arg__1, 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 that you ignore() the event if you do not understand it, so that the widget's parent can interpret it.
The default implementation closes popup widgets if the user presses Esc. Otherwise the event is ignored.
keyPressEvent
in class QWidget
public QSize minimumSizeHint()
Returns 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.
minimumSizeHint
in class QWidget
protected void mouseMoveEvent(QMouseEvent ev)
This event handler, for event arg__1, 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 Qt.
mouseMoveEvent
in class QWidget
Example
protected void mousePressEvent(QMouseEvent ev)
This event handler, for event arg__1, 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.
mousePressEvent
in class QWidget
Example
protected void mouseReleaseEvent(QMouseEvent ev)
This event handler, for event arg__1, can be reimplemented in a subclass to receive mouse release events for the widget.
mouseReleaseEvent
in class QWidget
Example
protected void paintEvent(QPaintEvent arg__1)
This event handler can be reimplemented in a subclass to receive paint events which are passed in the arg__1 parameter.
A paint event is a request to repaint all or part of the widget. It can happen as a result of repaint or update, or because the widget was obscured and has now been uncovered, or for many other 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.
Qt 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, Qt merges these events into one event with a larger region (see QRegion::united()). repaint 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 that you're painting on the widget's background.
The background can be set using setBackgroundRole and setPalette.
From Qt 4.0, QWidget automatically double-buffers its painting, so there's no need to write double-buffering code in paintEvent to avoid flicker.
Note: Under X11 it is possible to toggle the global double buffering by calling qt_x11_set_global_double_buffer(). Example usage:
... extern void qt_x11_set_global_double_buffer(bool); qt_x11_set_global_double_buffer(false); ...
Note: In general, one should refrain from calling update or repaint inside of 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.
paintEvent
in class QFrame
public QSize sizeHint()
Returns the recommended size for the widget.
If the value of this property is an invalid size, no size is recommended.
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.
sizeHint
in class QFrame
public static QLabel fromNativePointer(QNativePointer nativePointer)
nativePointer
- the QNativePointer of which object should be returned.public final QPicture picture()
public final QPixmap pixmap()
|
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |