Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qtextbrowser.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QTEXTBROWSER_H
5#define QTEXTBROWSER_H
6
7#include <QtWidgets/qtwidgetsglobal.h>
8#include <QtWidgets/qtextedit.h>
9#include <QtCore/qurl.h>
10
11QT_REQUIRE_CONFIG(textbrowser);
12
14
16
17class Q_WIDGETS_EXPORT QTextBrowser : public QTextEdit
18{
20
21 Q_PROPERTY(QUrl source READ source WRITE setSource)
22 Q_PROPERTY(QTextDocument::ResourceType sourceType READ sourceType)
23 Q_OVERRIDE(bool modified SCRIPTABLE false)
24 Q_OVERRIDE(bool readOnly DESIGNABLE false SCRIPTABLE false)
25 Q_OVERRIDE(bool undoRedoEnabled DESIGNABLE false SCRIPTABLE false)
26 Q_PROPERTY(QStringList searchPaths READ searchPaths WRITE setSearchPaths)
27 Q_PROPERTY(bool openExternalLinks READ openExternalLinks WRITE setOpenExternalLinks)
28 Q_PROPERTY(bool openLinks READ openLinks WRITE setOpenLinks)
29
30public:
31 explicit QTextBrowser(QWidget* parent = nullptr);
32 virtual ~QTextBrowser();
33
34 QUrl source() const;
35 QTextDocument::ResourceType sourceType() const;
36
37 QStringList searchPaths() const;
38 void setSearchPaths(const QStringList &paths);
39
40 virtual QVariant loadResource(int type, const QUrl &name) override;
41
42 bool isBackwardAvailable() const;
43 bool isForwardAvailable() const;
44 void clearHistory();
45 QString historyTitle(int) const;
46 QUrl historyUrl(int) const;
47 int backwardHistoryCount() const;
48 int forwardHistoryCount() const;
49
50 bool openExternalLinks() const;
51 void setOpenExternalLinks(bool open);
52
53 bool openLinks() const;
54 void setOpenLinks(bool open);
55
56public Q_SLOTS:
58 virtual void backward();
59 virtual void forward();
60 virtual void home();
61 virtual void reload();
62
65 void forwardAvailable(bool);
67 void sourceChanged(const QUrl &);
68 void highlighted(const QUrl &);
69 void anchorClicked(const QUrl &);
70
71protected:
72 bool event(QEvent *e) override;
73 virtual void keyPressEvent(QKeyEvent *ev) override;
74 virtual void mouseMoveEvent(QMouseEvent *ev) override;
75 virtual void mousePressEvent(QMouseEvent *ev) override;
76 virtual void mouseReleaseEvent(QMouseEvent *ev) override;
77 virtual void focusOutEvent(QFocusEvent *ev) override;
78 virtual bool focusNextPrevChild(bool next) override;
79 virtual void paintEvent(QPaintEvent *e) override;
81
82private:
83 Q_DISABLE_COPY(QTextBrowser)
84 Q_DECLARE_PRIVATE(QTextBrowser)
85 Q_PRIVATE_SLOT(d_func(), void _q_documentModified())
86 Q_PRIVATE_SLOT(d_func(), void _q_activateAnchor(const QString &))
87 Q_PRIVATE_SLOT(d_func(), void _q_highlightLink(const QString &))
88};
89
91
92#endif // QTEXTBROWSER_H
\inmodule QtCore
Definition qcoreevent.h:45
The QFocusEvent class contains event parameters for widget focus events.
Definition qevent.h:469
The QKeyEvent class describes a key event.
Definition qevent.h:423
\inmodule QtGui
Definition qevent.h:195
The QPaintEvent class contains event parameters for paint events.
Definition qevent.h:485
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
The QTextBrowser class provides a rich text browser with hypertext navigation.
void backwardAvailable(bool)
This signal is emitted when the availability of backward() changes.
void highlighted(const QUrl &)
This signal is emitted when the user has selected but not activated an anchor in the document.
void anchorClicked(const QUrl &)
This signal is emitted when the user clicks an anchor.
void historyChanged()
void forwardAvailable(bool)
This signal is emitted when the availability of forward() changes.
void sourceChanged(const QUrl &)
This signal is emitted when the source has changed, src being the new source.
ResourceType
This enum describes the types of resources that can be loaded by QTextDocument's loadResource() funct...
The QTextEdit class provides a widget that is used to edit and display both plain and rich text.
Definition qtextedit.h:27
virtual void paintEvent(QPaintEvent *e) override
This event handler can be reimplemented in a subclass to receive paint events passed in event.
virtual void mousePressEvent(QMouseEvent *e) override
\reimp
virtual bool focusNextPrevChild(bool next) override
\reimp
virtual void mouseReleaseEvent(QMouseEvent *e) override
\reimp
virtual void keyPressEvent(QKeyEvent *e) override
\reimp
virtual Q_INVOKABLE QVariant loadResource(int type, const QUrl &name)
Loads the resource specified by the given type and name.
virtual void mouseMoveEvent(QMouseEvent *e) override
\reimp
virtual void focusOutEvent(QFocusEvent *e) override
\reimp
\inmodule QtCore
Definition qurl.h:94
\inmodule QtCore
Definition qvariant.h:64
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
double e
short next
Definition keywords.cpp:445
Combined button and popup list for selecting options.
GLenum type
GLsizei const GLuint * paths
GLuint name
GLsizei GLsizei GLchar * source
struct _cl_event * event
#define QT_REQUIRE_CONFIG(feature)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_SLOTS
#define Q_PRIVATE_SLOT(d, signature)
#define Q_SIGNALS
#define Q_OVERRIDE(text)
file open(QIODevice::ReadOnly)
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent