How to Use QPushButton/de: Difference between revisions
m (Simow moved page How to Use QPushButton German to How to Use QPushButton/de: Localisation) |
|||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{Cleanup | reason=Auto-imported from ExpressionEngine.}} | {{Cleanup | reason=Auto-imported from ExpressionEngine.}} | ||
[[Category:HowTo/de]] | |||
{{LangSwitch}} | |||
= Verwendung von QPushButton = | |||
== Überblick == | |||
Mit der Klasse {{DocLink|QPushButton}} kann man als Entwickler Schaltflächen erstellen und bearbeiten. Diese Klasse kann einfach genutzt und angepasst werden und zählt deshalb zu den nützlichsten Klassen in Qt. Normalerweise zeigen Schaltflächen Text an, es können Icons daraufgeladen und angezeigt werden. | |||
QPushButton erbt von {{DocLink|QAbstractButton}} welcher wiederum von {{DocLink|QWidget}} erbt. | |||
== | == Signale == | ||
=== Vererbt von QAbstractButton === | |||
= | * <tt>void clicked(bool checked = false)</tt> | ||
* <tt>void pressed()</tt> | |||
* <tt>void released()</tt> | |||
* <tt>void toggled(bool checked)</tt> | |||
=== Vererbt von QWidget === | |||
* <tt>void customContextMenuRequested(const QPoint &pos)</tt> | |||
=== Vererbt von QObject === | |||
= | * <tt>void destroyed(QObject *obj = nullptr)</tt> | ||
== Verwendung == | == Verwendung == | ||
Line 36: | Line 33: | ||
=== Text === | === Text === | ||
Den Text, der | Den Text, der auf dem Knopf angezeigt werden soll, kann mit <tt>[https://doc.qt.io/qt-6/qabstractbutton.html#text-prop setText()]</tt> festgelegt werden. Den aktuell angezeigten Text bekommt man mit text(). | ||
=== Icon === | === Icon === | ||
Line 58: | Line 55: | ||
quit.setText("Beenden…"); | quit.setText("Beenden…"); | ||
QObject::connect(& | QObject::connect(&quit, SIGNAL (clicked()), &app, SLOT (quit())); | ||
quit.show(); | quit.show(); |
Latest revision as of 08:52, 8 November 2024
This article may require cleanup to meet the Qt Wiki's quality standards. Reason: Auto-imported from ExpressionEngine. Please improve this article if you can. Remove the {{cleanup}} tag and add this page to Updated pages list after it's clean. |
Verwendung von QPushButton
Überblick
Mit der Klasse QPushButton kann man als Entwickler Schaltflächen erstellen und bearbeiten. Diese Klasse kann einfach genutzt und angepasst werden und zählt deshalb zu den nützlichsten Klassen in Qt. Normalerweise zeigen Schaltflächen Text an, es können Icons daraufgeladen und angezeigt werden.
QPushButton erbt von QAbstractButton welcher wiederum von QWidget erbt.
Signale
Vererbt von QAbstractButton
- void clicked(bool checked = false)
- void pressed()
- void released()
- void toggled(bool checked)
Vererbt von QWidget
- void customContextMenuRequested(const QPoint &pos)
Vererbt von QObject
- void destroyed(QObject *obj = nullptr)
Verwendung
Text
Den Text, der auf dem Knopf angezeigt werden soll, kann mit setText() festgelegt werden. Den aktuell angezeigten Text bekommt man mit text().
Icon
Ein Icon kann man mit setIcon() spezifizieren, während man das aktuelle Icon mit icon() bekommt.
Beispiel
Ein Beispiel für einen QPushButton:
- include <QApplication>
- include <QPushButton>
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
QPushButton quit;
quit.setText("Beenden…");
QObject::connect(&quit, SIGNAL (clicked()), &app, SLOT (quit()));
quit.show();
return app.exec();
}