Qt Signal Slot Const Reference
Signals and Slots Signals and slots are used for communication between objects. The signal/slot mechanism is a central feature of Qt and probably the part that differs most from other toolkits. In most GUI toolkits widgets have a callback for each action they can trigger. This callback is a. The socket notifier is enabled by default, i.e. It emits the activated signal whenever a socket event corresponding to its type occurs. Connect the activated signal to the slot you want to be called when an event corresponding to your socket notifier's type occurs. There are three types of socket notifiers: read, write, and exception. Represents the exported D-Bus signal GroupsChanged on this object. Adaptees should export this signal as a Qt signal with the following signature: void groupsChanged(const Tp::UIntList& contact, const QStringList& added, const QStringList& removed); The adaptee signal will be automatically relayed as a D-Bus signal once emitted.
The QTextBrowser class provides a rich text browser with hypertext navigation. More...
Header: | #include <QTextBrowser> |
qmake: | QT += widgets |
Inherits: | QTextEdit |
Properties
|
|
- 17 properties inherited from QTextEdit
- 3 properties inherited from QAbstractScrollArea
- 6 properties inherited from QFrame
- 58 properties inherited from QWidget
- 1 property inherited from QObject
Public Functions
QTextBrowser(QWidget *parent = Q_NULLPTR) | |
int | backwardHistoryCount() const |
void | clearHistory() |
int | forwardHistoryCount() const |
QString | historyTitle(int i) const |
QUrl | historyUrl(int i) const |
bool | isBackwardAvailable() const |
bool | isForwardAvailable() const |
bool | openExternalLinks() const |
bool | openLinks() const |
QStringList | searchPaths() const |
void | setOpenExternalLinks(bool open) |
void | setOpenLinks(bool open) |
void | setSearchPaths(const QStringList &paths) |
QUrl | source() const |
Reimplemented Public Functions
virtual QVariant | loadResource(int type, const QUrl &name) |
- 62 public functions inherited from QTextEdit
- 20 public functions inherited from QAbstractScrollArea
- 14 public functions inherited from QFrame
- 211 public functions inherited from QWidget
- 31 public functions inherited from QObject
- 14 public functions inherited from QPaintDevice
Public Slots
virtual void | backward() |
virtual void | forward() |
virtual void | home() |
virtual void | reload() |
virtual void | setSource(const QUrl &name) |
- 25 public slots inherited from QTextEdit
- 19 public slots inherited from QWidget
- 1 public slot inherited from QObject
Signals
void | anchorClicked(const QUrl &link) |
void | backwardAvailable(bool available) |
void | forwardAvailable(bool available) |
void | highlighted(const QUrl &link) |
void | highlighted(const QString &link) |
void | historyChanged() |
void | sourceChanged(const QUrl &src) |
- 7 signals inherited from QTextEdit
- 3 signals inherited from QWidget
- 2 signals inherited from QObject
Reimplemented Protected Functions
virtual bool | event(QEvent *e) |
virtual bool | focusNextPrevChild(bool next) |
virtual void | focusOutEvent(QFocusEvent *ev) |
virtual void | keyPressEvent(QKeyEvent *ev) |
virtual void | mouseMoveEvent(QMouseEvent *e) |
virtual void | mousePressEvent(QMouseEvent *e) |
virtual void | mouseReleaseEvent(QMouseEvent *e) |
virtual void | paintEvent(QPaintEvent *e) |
Qt Signal Slot Const Reference Example
- 24 protected functions inherited from QTextEdit
- 20 protected functions inherited from QAbstractScrollArea
- 4 protected functions inherited from QFrame
- 35 protected functions inherited from QWidget
- 9 protected functions inherited from QObject
- 1 protected function inherited from QPaintDevice
Additional Inherited Members
- 1 public variable inherited from QObject
- 5 static public members inherited from QWidget
- 10 static public members inherited from QObject
- 24 protected functions inherited from QTextEdit
- 20 protected functions inherited from QAbstractScrollArea
- 4 protected functions inherited from QFrame
- 35 protected functions inherited from QWidget
- 9 protected functions inherited from QObject
- 1 protected function inherited from QPaintDevice
- 1 protected slot inherited from QWidget
- 2 protected variables inherited from QObject
- 1 protected type inherited from QPaintDevice
Detailed Description
The QTextBrowser class provides a rich text browser with hypertext navigation.
This class extends QTextEdit (in read-only mode), adding some navigation functionality so that users can follow links in hypertext documents.
If you want to provide your users with an editable rich text editor, use QTextEdit. If you want a text browser without hypertext navigation use QTextEdit, and use QTextEdit::setReadOnly() to disable editing. If you just need to display a small piece of rich text use QLabel.
Document Source and Contents
The contents of QTextEdit are set with setHtml() or setPlainText(), but QTextBrowser also implements the setSource() function, making it possible to use a named document as the source text. The name is looked up in a list of search paths and in the directory of the current document factory.
If a document name ends with an anchor (for example, '#anchor'
), the text browser automatically scrolls to that position (using scrollToAnchor()). When the user clicks on a hyperlink, the browser will call setSource() itself with the link's href
value as argument. You can track the current source by connecting to the sourceChanged() signal.
Navigation
QTextBrowser provides backward() and forward() slots which you can use to implement Back and Forward buttons. The home() slot sets the text to the very first document displayed. The anchorClicked() signal is emitted when the user clicks an anchor. To override the default navigation behavior of the browser, call the setSource() function to supply new document text in a slot connected to this signal.
If you want to load documents stored in the Qt resource system use qrc
as the scheme in the URL to load. For example, for the document resource path :/docs/index.html
use qrc:/docs/index.html
as the URL with setSource().
See also QTextEdit and QTextDocument.
Property Documentation
modified : const bool
This property holds whether the contents of the text browser have been modified.
openExternalLinks : bool
Specifies whether QTextBrowser should automatically open links to external sources using QDesktopServices::openUrl() instead of emitting the anchorClicked signal. Links are considered external if their scheme is neither file or qrc.
The default value is false.
This property was introduced in Qt 4.2.
Access functions:
bool | openExternalLinks() const |
void | setOpenExternalLinks(bool open) |
openLinks : bool
This property specifies whether QTextBrowser should automatically open links the user tries to activate by mouse or keyboard.
Regardless of the value of this property the anchorClicked signal is always emitted.
The default value is true.
This property was introduced in Qt 4.3.
Access functions:
bool | openLinks() const |
void | setOpenLinks(bool open) |
readOnly : const bool
This property holds whether the text browser is read-only.
By default, this property is true
.
searchPaths : QStringList
This property holds the search paths used by the text browser to find supporting content.
QTextBrowser uses this list to locate images and documents.
By default, this property contains an empty string list.
Access functions:
QStringList | searchPaths() const |
void | setSearchPaths(const QStringList &paths) |
source : QUrl
This property holds the name of the displayed document.
This is a an invalid url if no document is displayed or if the source is unknown.
When setting this property QTextBrowser tries to find a document with the specified name in the paths of the searchPaths property and directory of the current source, unless the value is an absolute file path. It also checks for optional anchors and scrolls the document accordingly
If the first tag in the document is <qt type=detail>
, the document is displayed as a popup rather than as new document in the browser window itself. Otherwise, the document is displayed normally in the text browser with the text set to the contents of the named document with setHtml().
By default, this property contains an empty URL.
Access functions:
QUrl | source() const |
virtual void | setSource(const QUrl &name) |
undoRedoEnabled : const bool
This property holds whether the text browser supports undo/redo operations.
By default, this property is false
.
Member Function Documentation
QTextBrowser::QTextBrowser(QWidget *parent = Q_NULLPTR)
Constructs an empty QTextBrowser with parent parent.
[signal]
void QTextBrowser::anchorClicked(const QUrl &link)
This signal is emitted when the user clicks an anchor. The URL referred to by the anchor is passed in link.
Note that the browser will automatically handle navigation to the location specified by link unless the openLinks property is set to false or you call setSource() in a slot connected. This mechanism is used to override the default navigation features of the browser.
[virtual slot]
void QTextBrowser::backward()
Changes the document displayed to the previous document in the list of documents built by navigating links. Does nothing if there is no previous document.
See also forward() and backwardAvailable().
[signal]
void QTextBrowser::backwardAvailable(boolavailable)
This signal is emitted when the availability of backward() changes. available is false when the user is at home(); otherwise it is true.
int QTextBrowser::backwardHistoryCount() const
Returns the number of locations backward in the history.
This function was introduced in Qt 4.4.
void QTextBrowser::clearHistory()
Clears the history of visited documents and disables the forward and backward navigation.
This function was introduced in Qt 4.2.
See also backward() and forward().
[virtual protected]
bool QTextBrowser::event(QEvent *e)
Reimplemented from QObject::event().
[virtual protected]
bool QTextBrowser::focusNextPrevChild(boolnext)
Reimplemented from QWidget::focusNextPrevChild().
[virtual protected]
void QTextBrowser::focusOutEvent(QFocusEvent *ev)
Reimplemented from QWidget::focusOutEvent().
[virtual slot]
void QTextBrowser::forward()
Changes the document displayed to the next document in the list of documents built by navigating links. Does nothing if there is no next document.
See also backward() and forwardAvailable().
[signal]
void QTextBrowser::forwardAvailable(boolavailable)
This signal is emitted when the availability of forward() changes. available is true after the user navigates backward() and false when the user navigates or goes forward().
int QTextBrowser::forwardHistoryCount() const
Returns the number of locations forward in the history.
This function was introduced in Qt 4.4.
[signal]
void QTextBrowser::highlighted(const QUrl &link)
This signal is emitted when the user has selected but not activated an anchor in the document. The URL referred to by the anchor is passed in link.
Note: Signal highlighted is overloaded in this class. To connect to this one using the function pointer syntax, you must specify the signal type in a static cast, as shown in this example:
[signal]
void QTextBrowser::highlighted(const QString &link)
This is an overloaded function.
Convenience signal that allows connecting to a slot that takes just a QString, like for example QStatusBar's message().
Note: Signal highlighted is overloaded in this class. To connect to this one using the function pointer syntax, you must specify the signal type in a static cast, as shown in this example:
[signal]
void QTextBrowser::historyChanged()
This signal is emitted when the history changes.
This function was introduced in Qt 4.4.
See also historyTitle() and historyUrl().
QString QTextBrowser::historyTitle(inti) const
Returns the documentTitle() of the HistoryItem.
Input | Return |
---|---|
i < 0 | backward() history |
i 0 | current, see QTextBrowser::source() |
i > 0 | forward() history |
This function was introduced in Qt 4.4.
QUrl QTextBrowser::historyUrl(inti) const
Returns the url of the HistoryItem.
Input | Return |
---|---|
i < 0 | backward() history |
i 0 | current, see QTextBrowser::source() |
i > 0 | forward() history |
This function was introduced in Qt 4.4.
[virtual slot]
void QTextBrowser::home()
Changes the document displayed to be the first document from the history.
bool QTextBrowser::isBackwardAvailable() const
Returns true
if the text browser can go backward in the document history using backward().
This function was introduced in Qt 4.2.
See also backwardAvailable() and backward().
bool QTextBrowser::isForwardAvailable() const
Returns true
if the text browser can go forward in the document history using forward().
This function was introduced in Qt 4.2.
See also forwardAvailable() and forward().
[virtual protected]
void QTextBrowser::keyPressEvent(QKeyEvent *ev)
Reimplemented from QWidget::keyPressEvent().
The event ev is used to provide the following keyboard shortcuts:
Keypress | Action |
---|---|
Alt+Left Arrow | backward() |
Alt+Right Arrow | forward() |
Alt+Up Arrow | home() |
[virtual]
QVariant QTextBrowser::loadResource(inttype, const QUrl &name)
Reimplemented from QTextEdit::loadResource().
This function is called when the document is loaded and for each image in the document. The type indicates the type of resource to be loaded. An invalid QVariant is returned if the resource cannot be loaded.
The default implementation ignores type and tries to locate the resources by interpreting name as a file name. If it is not an absolute path it tries to find the file in the paths of the searchPaths property and in the same directory as the current source. On success, the result is a QVariant that stores a QByteArray with the contents of the file.
If you reimplement this function, you can return other QVariant types. The table below shows which variant types are supported depending on the resource type:
ResourceType | QVariant::Type |
---|---|
QTextDocument::HtmlResource | QString or QByteArray |
QTextDocument::ImageResource | QImage, QPixmap or QByteArray |
QTextDocument::StyleSheetResource | QString or QByteArray |
[virtual protected]
void QTextBrowser::mouseMoveEvent(QMouseEvent *e)
Reimplemented from QWidget::mouseMoveEvent().
[virtual protected]
void QTextBrowser::mousePressEvent(QMouseEvent *e)
Reimplemented from QWidget::mousePressEvent().
[virtual protected]
void QTextBrowser::mouseReleaseEvent(QMouseEvent *e)
Reimplemented from QWidget::mouseReleaseEvent().
[virtual protected]
void QTextBrowser::paintEvent(QPaintEvent *e)
Reimplemented from QWidget::paintEvent().
[virtual slot]
void QTextBrowser::reload()
Reloads the current set source.
[signal]
void QTextBrowser::sourceChanged(const QUrl &src)
This signal is emitted when the source has changed, src being the new source.
Source changes happen both programmatically when calling setSource(), forward(), backword() or home() or when the user clicks on links or presses the equivalent key sequences.
Home All Classes Main Classes Annotated Grouped Classes Functions |
The QTabBar class provides a tab bar, e.g. for use in tabbed dialogs.More...
#include <qtabbar.h>
Inherits QWidget.
Public Members
- QTabBar ( QWidget * parent = 0, const char * name = 0 )
- ~QTabBar ()
- enum Shape { RoundedAbove, RoundedBelow, TriangularAbove, TriangularBelow }
- Shape shape () const
- virtual void setShape ( Shape )
- virtual int addTab ( QTab * newTab )
- virtual int insertTab ( QTab * newTab, int index = -1 )
- virtual void removeTab ( QTab * t )
- virtual void setTabEnabled ( int id, bool enabled )
- bool isTabEnabled ( int id ) const
- int currentTab () const
- int keyboardFocusTab () const
- QTab * tab ( int id ) const
- QTab * tabAt ( int index ) const
- int indexOf ( int id ) const
- int count () const
- virtual void layoutTabs ()
- virtual QTab * selectTab ( const QPoint & p ) const
- void removeToolTip ( int index )
- void setToolTip ( int index, const QString & tip )
- QString toolTip ( int index ) const
Public Slots
- virtual void setCurrentTab ( int )
- virtual void setCurrentTab ( QTab * tab )
Signals
- void selected ( int id )
- void layoutChanged ()
Properties
- int count - the number of tabs in the tab bar (read only)
- int currentTab - the id of the tab bar's visible tab
- int keyboardFocusTab - the id of the tab that has the keyboard focus (read only)
- Shape shape - the shape of the tabs in the tab bar
Protected Members
- virtual void paint ( QPainter * p, QTab * t, bool selected ) const
- virtual void paintLabel ( QPainter * p, const QRect & br, QTab * t, bool has_focus ) const
- virtual void paintEvent ( QPaintEvent * e )
- QPtrList<QTab> * tabList ()
Detailed Description
The QTabBar class provides a tab bar, e.g. for use in tabbed dialogs.QTabBar is straightforward to use; it draws the tabs using one ofthe predefined shapes, and emits asignal when a tab is selected. It can be subclassed to tailor thelook and feel. Qt also provides a ready-made QTabWidget and aQTabDialog.
The choice of tab shape is a matter of taste, although tab dialogs(for preferences and similar) invariably use RoundedAbove;nobody uses TriangularAbove. Tab controls in windows other thandialogs almost always use either RoundedBelow or TriangularBelow. Many spreadsheets and other tab controls in whichall the pages are essentially similar use TriangularBelow,whereas RoundedBelow is used mostly when the pages aredifferent (e.g. a multi-page tool palette).
The most important part of QTabBar's API is the selected() signal.This is emitted whenever the selected page changes (even atstartup, when the selected page changes from 'none'). There isalso a slot, setCurrentTab(), which can be used to select a pageprogrammatically.
QTabBar creates automatic accelerator keys in the manner ofQButton; e.g. if a tab's label is '&Graphics', Alt+G becomes anaccelerator key for switching to that tab.
The following virtual functions may need to be reimplemented:
- paint() paints a single tab. paintEvent() calls paint() foreach tab so that any overlap will look right.
- addTab() creates a new tab and adds it to the bar.
- selectTab() decides which tab, if any, the user selects with the mouse.
The index of the current tab is returned by currentTab(). The tabwith a particular index is returned by tabAt(), the tab with aparticular id is returned by tab(). The index of a tab is returnedby indexOf(). The current tab can be set by index or tab pointerusing one of the setCurrentTab() functions.
See also Advanced Widgets.
Member Type Documentation
QTabBar::Shape
This enum type lists the built-in shapes supported by QTabBar:
- QTabBar::RoundedAbove - the normal rounded look above the pages
- QTabBar::RoundedBelow - the normal rounded look below the pages
- QTabBar::TriangularAbove - triangular tabs above the pages (veryunusual; included for completeness)
- QTabBar::TriangularBelow - triangular tabs similar to those used inthe Excel spreadsheet, for example
Member Function Documentation
QTabBar::QTabBar ( QWidget * parent = 0, const char * name = 0 )
Constructs a new, empty tab bar; the parent and namearguments are passed on to the QWidget constructor.QTabBar::~QTabBar ()
Destroys the tab control, freeing memory used.int QTabBar::addTab ( QTab * newTab ) [virtual]
Adds the tab, newTab, to the tab control.Sets newTab's id to a new id and places the tab just to theright of the existing tabs. If the tab's label contains anampersand, the letter following the ampersand is used as anaccelerator for the tab, e.g. if the label is 'Bro&wse' thenAlt+W becomes an accelerator which will move the focus to thistab. Returns the id.
See also insertTab().
int QTabBar::count () const
Returns the number of tabs in the tab bar.See the 'count' property for details.
int QTabBar::currentTab () const
Returns the id of the tab bar's visible tab.See the 'currentTab' property for details.
int QTabBar::indexOf ( int id ) const
Returns the position index of the tab with id id or -1 if notab has this id.See also tabAt().
int QTabBar::insertTab ( QTab * newTab, int index = -1 ) [virtual]
Inserts the tab, newTab, into the tab control.If index is not specified, the tab is simply appended.Otherwise it's inserted at the specified position.
Sets newTab's id to a new id. If the tab's label contains anampersand, the letter following the ampersand is used as anaccelerator for the tab, e.g. if the label is 'Bro&wse' thenAlt+W becomes an accelerator which will move the focus to thistab. Returns the id.
See also addTab().
bool QTabBar::isTabEnabled ( int id ) const
Returns TRUE if the tab with id id exists and is enabled;otherwise returns FALSE.See also setTabEnabled().
int QTabBar::keyboardFocusTab () const
Returns the id of the tab that has the keyboard focus.See the 'keyboardFocusTab' property for details.
void QTabBar::layoutChanged () [signal]
QTabBar emits the signal whenever the layout of the tab bar hasbeen recalculated, for example when the contents of a tab change.
void QTabBar::layoutTabs () [virtual]
Lays out all existing tabs according to their label and theiriconset.void QTabBar::paint ( QPainter * p, QTab * t, bool selected ) const [virtual protected]
Paints the tab t using painter p. If and only if selectedis TRUE, t is drawn currently selected.This virtual function may be reimplemented to change the look ofQTabBar. If you decide to reimplement it, you may also need toreimplement sizeHint().
void QTabBar::paintEvent ( QPaintEvent * e ) [virtual protected]
Repaints the tab row. All the painting is done by paint();paintEvent() only decides which tabs need painting and in whatorder. The event is passed in e.See also paint().
Reimplemented from QWidget.
Qt Signal Slot Const Reference Guide
void QTabBar::paintLabel ( QPainter * p, const QRect & br, QTab * t, bool has_focus ) const [virtual protected]
Paints the label of tab t centered in rectangle br usingpainter p. A focus indication is drawn if has_focus is TRUE.void QTabBar::removeTab ( QTab * t ) [virtual]
Removes tab t from the tab control, and deletes the tab.void QTabBar::removeToolTip ( int index )
Removes the tool tip for the tab at index position index.QTab * QTabBar::selectTab ( const QPoint & p ) const [virtual]
This virtual function is called by the mouse event handlers todetermine which tab is pressed. The default implementation returnsa pointer to the tab whose bounding rectangle contains p, ifexactly one tab's bounding rectangle contains p. Otherwise itreturns 0.See also mousePressEvent() and mouseReleaseEvent().
void QTabBar::selected ( int id ) [signal]
QTabBar emits this signal whenever any tab is selected, whether bythe program or by the user. The argument id is the id of thetab as returned by addTab().
show() is guaranteed to emit this signal; you can display yourpage in a slot connected to this signal.
void QTabBar::setCurrentTab ( int ) [virtual slot]
Sets the id of the tab bar's visible tab.See the 'currentTab' property for details.
void QTabBar::setCurrentTab ( QTab * tab ) [virtual slot]
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.Raises tab and emits the selected() signal unless the tab wasalready current.
See also currentTab and selected().
void QTabBar::setShape ( Shape ) [virtual]
Sets the shape of the tabs in the tab bar.See the 'shape' property for details.
void QTabBar::setTabEnabled ( int id, bool enabled ) [virtual]
Enables tab id if enabled is TRUE or disables it if enabled is FALSE. If id is currently selected,setTabEnabled(FALSE) makes another tab selected.setTabEnabled() updates the display if this causes a change in id's status.
See also update() and isTabEnabled().
void QTabBar::setToolTip ( int index, const QString & tip )
Sets the tool tip for the tab at index position index to tip.ShapeQTabBar::shape () const
Returns the shape of the tabs in the tab bar.See the 'shape' property for details.
QTab * QTabBar::tab ( int id ) const
Returns the tab with id id or 0 if there is no such tab.See also count.
QTab * QTabBar::tabAt ( int index ) const
Returns the tab at position index.See also indexOf().
QPtrList<QTab> * QTabBar::tabList () [protected]
Qt Signal Slot Const Reference Sheet
The list of QTab objects in the tab bar.This list is unlikely to be in the order that the QTab elementsappear visually. One way of iterating over the tabs is like this:
QStringQTabBar::toolTip ( int index ) const
Returns the tool tip for the tab at index position index.Property Documentation
int count
This property holds the number of tabs in the tab bar.
Get this property's value with count().
See also tab().
int currentTab
This property holds the id of the tab bar's visible tab.
If no tab page is currently visible, the property's value is -1.Even if the property's value is not -1, you cannot assume that theuser can see the relevant page, or that the tab is enabled. Whenyou need to display something the value of this propertyrepresents the best page to display.
When this property is set to id, it will raise the tab with theid id and emit the selected() signal.
See also selected() and isTabEnabled().
Set this property's value with setCurrentTab() and get this property's value with currentTab().
Qt Signal Slot Const Reference Generator
int keyboardFocusTab
This property holds the id of the tab that has the keyboard focus.
This property contains the id of the tab that has the keyboardfocus or -1 if the tab bar does not have the keyboard focus.
Get this property's value with keyboardFocusTab().
Shapeshape
This property holds the shape of the tabs in the tab bar.
The value of this property is one of the following: RoundedAbove (default), RoundedBelow, TriangularAbove or TriangularBelow.
See also Shape.
Set this property's value with setShape() and get this property's value with shape().
This file is part of the Qt toolkit.Copyright © 1995-2005Trolltech. All Rights Reserved.