• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

Plasma

  • plasma
  • widgets
pushbutton.h
Go to the documentation of this file.
1/*
2 * Copyright 2008 Aaron Seigo <aseigo@kde.org>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Library General Public License as
6 * published by the Free Software Foundation; either version 2, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20#ifndef PLASMA_PUSHBUTTON_H
21#define PLASMA_PUSHBUTTON_H
22
23#include <QtGui/QGraphicsProxyWidget>
24
25#include <kicon.h>
26
27class KPushButton;
28
29#include <plasma/plasma_export.h>
30
31namespace Plasma
32{
33
34class PushButtonPrivate;
35
41class PLASMA_EXPORT PushButton : public QGraphicsProxyWidget
42{
43 Q_OBJECT
44
45 Q_PROPERTY(QGraphicsWidget *parentWidget READ parentWidget)
46 Q_PROPERTY(QString text READ text WRITE setText)
47 Q_PROPERTY(QString image READ image WRITE setImage)
48 Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet)
49 Q_PROPERTY(KPushButton *nativeWidget READ nativeWidget)
50 Q_PROPERTY(QAction *action READ action WRITE setAction)
51 Q_PROPERTY(QIcon icon READ icon WRITE setIcon)
52 Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable)
53 Q_PROPERTY(bool checked READ isChecked WRITE setChecked)
54 Q_PROPERTY(bool down READ isDown)
55
56public:
57 explicit PushButton(QGraphicsWidget *parent = 0);
58 ~PushButton();
59
65 void setText(const QString &text);
66
70 QString text() const;
71
77 void setImage(const QString &path);
78
87 void setImage(const QString &path, const QString &elementid);
88
92 QString image() const;
93
99 void setStyleSheet(const QString &stylesheet);
100
104 QString styleSheet();
105
113 void setAction(QAction *action);
114
120 QAction *action() const;
121
129 void setIcon(const QIcon &icon);
130
138 void setIcon(const KIcon &icon);
139
145 QIcon icon() const;
146
152 void setCheckable(bool checkable);
153
159 bool isCheckable() const;
160
167 bool isChecked() const;
168
173 bool isDown() const;
174
178 KPushButton *nativeWidget() const;
179
180Q_SIGNALS:
186 void pressed();
187
193 void released();
194
198 void clicked();
199
203 void toggled(bool);
204
205public Q_SLOTS:
210 void click();
211
217 void setChecked(bool checked);
218
219protected:
220 void paint(QPainter *painter,
221 const QStyleOptionGraphicsItem *option,
222 QWidget *widget = 0);
223 void resizeEvent(QGraphicsSceneResizeEvent *event);
224 void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
225 void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
226 void changeEvent(QEvent *event);
227 QSizeF sizeHint(Qt::SizeHint which, const QSizeF & constraint) const;
228
229private:
230 Q_PRIVATE_SLOT(d, void syncBorders())
231 Q_PRIVATE_SLOT(d, void setPixmap())
232 Q_PRIVATE_SLOT(d, void pressedChanged())
233 Q_PRIVATE_SLOT(d, void syncToAction())
234 Q_PRIVATE_SLOT(d, void clearAction())
235 Q_PRIVATE_SLOT(d, void setPalette())
236
237 friend class PushButtonPrivate;
238 PushButtonPrivate *const d;
239};
240
241} // namespace Plasma
242
243#endif // multiple inclusion guard
Plasma::PushButton::PushButtonPrivate
friend class PushButtonPrivate
Definition pushbutton.h:237
Plasma::PushButton::toggled
void toggled(bool)
Emitted when the button changes state from up to down.
Plasma::PushButton::down
bool down
Definition pushbutton.h:54
Plasma::PushButton::changeEvent
void changeEvent(QEvent *event)
Definition pushbutton.cpp:493
Plasma::PushButton::setCheckable
void setCheckable(bool checkable)
Sets whether or not this button can be toggled on/off.
Definition pushbutton.cpp:309
Plasma::PushButton::styleSheet
QString styleSheet
Definition pushbutton.h:48
Plasma::PushButton::sizeHint
QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
Definition pushbutton.cpp:519
Plasma::PushButton::click
void click()
Performs a visual click and emits the associated signals.
Definition pushbutton.cpp:324
Plasma::PushButton::setStyleSheet
void setStyleSheet(const QString &stylesheet)
Sets the stylesheet used to control the visual display of this PushButton.
Definition pushbutton.cpp:273
Plasma::PushButton::icon
QIcon icon
Definition pushbutton.h:51
Plasma::PushButton::hoverLeaveEvent
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
Definition pushbutton.cpp:499
Plasma::PushButton::checkable
bool checkable
Definition pushbutton.h:52
Plasma::PushButton::isCheckable
bool isCheckable() const
Definition pushbutton.cpp:314
Plasma::PushButton::paint
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0)
Definition pushbutton.cpp:353
Plasma::PushButton::isChecked
bool isChecked() const
Definition pushbutton.cpp:329
Plasma::PushButton::isDown
bool isDown() const
Definition pushbutton.cpp:334
Plasma::PushButton::setChecked
void setChecked(bool checked)
Sets whether or not this button is checked.
Definition pushbutton.cpp:319
Plasma::PushButton::image
QString image
Definition pushbutton.h:47
Plasma::PushButton::PushButton
PushButton(QGraphicsWidget *parent=0)
Definition pushbutton.cpp:182
Plasma::PushButton::nativeWidget
KPushButton * nativeWidget
Definition pushbutton.h:49
Plasma::PushButton::hoverEnterEvent
void hoverEnterEvent(QGraphicsSceneHoverEvent *event)
Definition pushbutton.cpp:474
Plasma::PushButton::checked
bool checked
Definition pushbutton.h:53
Plasma::PushButton::clicked
void clicked()
Emitted when the button is pressed then released, completing a click.
Plasma::PushButton::setImage
void setImage(const QString &path)
Sets the path to an image to display.
Definition pushbutton.cpp:234
Plasma::PushButton::setIcon
void setIcon(const QIcon &icon)
sets the icon for this push button
Definition pushbutton.cpp:299
Plasma::PushButton::pressed
void pressed()
Emitted when the button is pressed down; usually the clicked() signal will suffice,...
Plasma::PushButton::parentWidget
QGraphicsWidget * parentWidget
Definition pushbutton.h:45
Plasma::PushButton::resizeEvent
void resizeEvent(QGraphicsSceneResizeEvent *event)
Definition pushbutton.cpp:344
Plasma::PushButton::setAction
void setAction(QAction *action)
Associate an action with this IconWidget this makes the button follow the state of the action,...
Definition pushbutton.cpp:284
Plasma::PushButton::released
void released()
Emitted when the button is released; usually the clicked() signal will suffice, however.
Plasma::PushButton::action
QAction * action
Definition pushbutton.h:50
Plasma::PushButton::setText
void setText(const QString &text)
Sets the display text for this PushButton.
Definition pushbutton.cpp:223
Plasma::PushButton::text
QString text
Definition pushbutton.h:46
QGraphicsProxyWidget
QGraphicsWidget
QStyleOptionGraphicsItem
QWidget
Plasma
Namespace for everything in libplasma.
Definition abstractdialogmanager.cpp:25
plasma_export.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Tue Mar 25 2025 00:00:00 by doxygen 1.14.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Plasma

Skip menu "Plasma"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal