KTitleWidget Class
Standard title widget. More...
- Header:
#include <KTitleWidget> - CMake:
find_package(KF6 REQUIRED COMPONENTS WidgetsAddons)
target_link_libraries(mytarget PRIVATE KF6::WidgetsAddons) - Inherits: QWidget
List of all members, including inherited members
Public Types
Properties
- autoHideTimeout : int
- comment : QString
- icon : QIcon
- iconSize : QSize
- text : QString
- [since 6.26] textSelectable : int
Public Functions
- KTitleWidget(QWidget *parent = nullptr)
- int autoHideTimeout() const
- QString comment() const
- QIcon icon() const
- QSize iconSize() const
- int level()
- void setBuddy(QWidget *buddy)
- void setWidget(QWidget *widget)
- QString text() const
- bool textSelectable() const (since 6.26)
Public Slots
- void setAutoHideTimeout(int msecs)
- void setComment(const QString &comment, KTitleWidget::MessageType type = PlainMessage)
- void setIcon(KTitleWidget::MessageType type, KTitleWidget::ImageAlignment alignment = ImageRight)
- void setIcon(const QIcon &icon, KTitleWidget::ImageAlignment alignment = ImageRight)
- void setIconSize(const QSize &iconSize)
- void setLevel(int level)
- void setText(const QString &text, KTitleWidget::MessageType type)
- void setText(const QString &text, Qt::Alignment alignment = Qt::AlignLeft | Qt::AlignVCenter)
- void setTextSelectable(bool selectable) (since 6.26)
Detailed Description
This class provides a widget often used for dialog titles.
KTitleWidget uses the general application font at 1.4 times its size to style the text. This is a visual change from 4.x.
Usage:
KTitleWidget is very simple to use. You can either use its default text (and pixmap) properties or display your own widgets in the title widget.
A title text with a right-aligned pixmap:
KTitleWidget *titleWidget = new KTitleWidget(this);
titleWidget->setText(i18n("Title"));
titleWidget->setIcon(QIcon::fromTheme("screen"));
Use it with an own widget:
KTitleWidget *checkboxTitleWidget = new KTitleWidget(this);
QWidget *checkBoxTitleMainWidget = new QWidget(this);
QVBoxLayout *titleLayout = new QVBoxLayout(checkBoxTitleMainWidget);
titleLayout->setContentsMargins(6, 6, 6, 6);
QCheckBox *checkBox = new QCheckBox("Text Checkbox", checkBoxTitleMainWidget);
titleLayout->addWidget(checkBox);
checkboxTitleWidget->setWidget(checkBoxTitleMainWidget);
See also KPageView
Member Type Documentation
enum KTitleWidget::ImageAlignment
Possible title pixmap alignments.
| Constant | Value | Description |
|---|---|---|
KTitleWidget::ImageLeft |
0 |
Display the pixmap left |
KTitleWidget::ImageRight |
1 |
Display the pixmap right (default) |
enum KTitleWidget::MessageType
Comment message types
| Constant | Value | Description |
|---|---|---|
KTitleWidget::PlainMessage |
0 |
Normal comment |
KTitleWidget::InfoMessage |
1 |
Information the user should be alerted to |
KTitleWidget::WarningMessage |
2 |
A warning the user should be alerted to |
KTitleWidget::ErrorMessage |
3 |
An error message |
Property Documentation
autoHideTimeout : int
Access functions:
intautoHideTimeout() constvoidsetAutoHideTimeout(intmsecs)
comment : QString
Access functions:
QStringcomment() constvoidsetComment(constQString&comment,KTitleWidget::MessageTypetype = PlainMessage)
icon : QIcon
Access functions:
QIconicon() constvoidsetIcon(constQIcon&icon,KTitleWidget::ImageAlignmentalignment = ImageRight)voidsetIcon(KTitleWidget::MessageTypetype,KTitleWidget::ImageAlignmentalignment = ImageRight)
iconSize : QSize
Access functions:
QSizeiconSize() constvoidsetIconSize(constQSize&iconSize)
text : QString
Access functions:
QStringtext() constvoidsetText(constQString&text,Qt::Alignmentalignment = Qt::AlignLeft | Qt::AlignVCenter)voidsetText(constQString&text,KTitleWidget::MessageTypetype)
[since 6.26] textSelectable : int
This property was introduced in Qt 6.26.
Access functions:
booltextSelectable() constvoidsetTextSelectable(boolselectable)
Member Function Documentation
[explicit] KTitleWidget::KTitleWidget(QWidget *parent = nullptr)
Constructs a title widget.
int KTitleWidget::autoHideTimeout() const
Get the current timeout value in milliseconds
Returns timeout value in msecs
Note: Getter function for property autoHideTimeout.
See also setAutoHideTimeout()
QString KTitleWidget::comment() const
Returns the text displayed in the comment below the title, if any
Note: Getter function for property comment.
See also setComment()
QIcon KTitleWidget::icon() const
Returns the icon displayed in the title
Note: Getter function for property icon.
See also setIcon()
QSize KTitleWidget::iconSize() const
Returns the size of the icon displayed in the title
Note: Getter function for property iconSize.
See also setIconSize()
int KTitleWidget::level()
Returns the level of this title: it influences the font size following the guidelines in the KDE HIG. It also corresponds to the level api of Kirigami Heading for QML applications
Note: The default level is 1.
See also setLevel()
[slot] void KTitleWidget::setAutoHideTimeout(int msecs)
Set the autohide timeout of the label
Set value to 0 to disable autohide, which is the default.
msecs timeout value in milliseconds
Note: Setter function for property autoHideTimeout.
See also autoHideTimeout()
void KTitleWidget::setBuddy(QWidget *buddy)
Sets this label's buddy to buddy.
When the user presses the shortcut key indicated by the label in this title widget, the keyboard focus is transferred to the label's buddy widget.
buddy the widget to activate when the shortcut key is activated
[slot] void KTitleWidget::setComment(const QString &comment, KTitleWidget::MessageType type = PlainMessage)
comment Text displayed beneath the main title as a comment. It can either be plain text or rich text.
type The sort of message it is.
Note: Setter function for property comment.
See also comment()
[slot] void KTitleWidget::setIcon(KTitleWidget::MessageType type, KTitleWidget::ImageAlignment alignment = ImageRight)
type the type of message icon to display in the header
alignment alignment of the icon (default is right aligned).
Note: Setter function for property icon.
Note: This slot is overloaded. To connect to this slot:
// Connect using qOverload: connect(sender, &SenderClass::signal, kTitleWidget, qOverload<KTitleWidget::MessageType, KTitleWidget::ImageAlignment>(&KTitleWidget::setIcon)); // Or using a lambda as wrapper: connect(sender, &SenderClass::signal, kTitleWidget, [receiver = kTitleWidget](KTitleWidget::MessageType type, KTitleWidget::ImageAlignment alignment) { receiver->setIcon(type, alignment); });For more examples and approaches, see connecting to overloaded slots.
See also icon()
[slot] void KTitleWidget::setIcon(const QIcon &icon, KTitleWidget::ImageAlignment alignment = ImageRight)
Set the icon to display in the header.
icon the icon to display in the header.
alignment alignment of the icon (default is right aligned).
Note: Setter function for property icon.
Note: This slot is overloaded. To connect to this slot:
// Connect using qOverload: connect(sender, &SenderClass::signal, kTitleWidget, qOverload<const QIcon &, KTitleWidget::ImageAlignment>(&KTitleWidget::setIcon)); // Or using a lambda as wrapper: connect(sender, &SenderClass::signal, kTitleWidget, [receiver = kTitleWidget](const QIcon &icon, KTitleWidget::ImageAlignment alignment) { receiver->setIcon(icon, alignment); });For more examples and approaches, see connecting to overloaded slots.
[slot] void KTitleWidget::setIconSize(const QSize &iconSize)
Set the size of the icon to display in the header.
iconSize the size of the icon, or an invalid QSize to reset to the default
The default size is defined by the GUI style and its value for QStyle::PM_MessageBoxIconSize.
Note: Setter function for property iconSize.
See also iconSize()
[slot] void KTitleWidget::setLevel(int level)
Sets the level of this title, similar to HTML's h1 h2 h3...
Follows the KDE HIG.
level the level of the title, 1 is the biggest font and most important, descending
See also level()
[slot] void KTitleWidget::setText(const QString &text, KTitleWidget::MessageType type)
text Text displayed on the label. It can either be plain text or rich text.
type The sort of message it is; will also set the icon accordingly
Note: Setter function for property text.
Note: This slot is overloaded. To connect to this slot:
// Connect using qOverload: connect(sender, &SenderClass::signal, kTitleWidget, qOverload<const QString &, KTitleWidget::MessageType>(&KTitleWidget::setText)); // Or using a lambda as wrapper: connect(sender, &SenderClass::signal, kTitleWidget, [receiver = kTitleWidget](const QString &text, KTitleWidget::MessageType type) { receiver->setText(text, type); });For more examples and approaches, see connecting to overloaded slots.
See also text()
[slot] void KTitleWidget::setText(const QString &text, Qt::Alignment alignment = Qt::AlignLeft | Qt::AlignVCenter)
text Text displayed on the label. It can either be plain text or rich text.
alignment Alignment of the text. Default is left and vertical centered.
Note: Setter function for property text.
Note: This slot is overloaded. To connect to this slot:
// Connect using qOverload: connect(sender, &SenderClass::signal, kTitleWidget, qOverload<const QString &, Qt::Alignment>(&KTitleWidget::setText)); // Or using a lambda as wrapper: connect(sender, &SenderClass::signal, kTitleWidget, [receiver = kTitleWidget](const QString &text, Qt::Alignment alignment) { receiver->setText(text, alignment); });For more examples and approaches, see connecting to overloaded slots.
See also text()
[slot, since 6.26] void KTitleWidget::setTextSelectable(bool selectable)
Sets whether the text is selectable or not.
selectable whether the text is selectable, defaults to true.
Note: Setter function for property textSelectable.
This function was introduced in Qt 6.26.
See also textSelectable()
void KTitleWidget::setWidget(QWidget *widget)
widget Widget displayed on the title widget.
QString KTitleWidget::text() const
Returns the text displayed in the title
Note: Getter function for property text.
See also setText()
[since 6.26] bool KTitleWidget::textSelectable() const
Returns if the text is selectable
Note: Getter function for property textSelectable.
This function was introduced in Qt 6.26.
See also setTextSelectable()