Qt 4.8
qtoolbarextension.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qtoolbarextension_p.h"
43 #include <qpixmap.h>
44 #include <qstyle.h>
45 #include <qstylepainter.h>
46 #include <qstyleoption.h>
47 
48 #ifndef QT_NO_TOOLBUTTON
49 
51 
53  : QToolButton(parent)
54 {
55  setObjectName(QLatin1String("qt_toolbar_ext_button"));
56  setAutoRaise(true);
59  setCheckable(true);
60 }
61 
63 {
64  QStyleOption opt;
65  opt.init(this);
66  if (o == Qt::Horizontal) {
68  } else {
70  }
71 }
72 
74 {
75  QStylePainter p(this);
77  initStyleOption(&opt);
78  // We do not need to draw both extension arrows
79  opt.features &= ~QStyleOptionToolButton::HasMenu;
81 }
82 
83 
85 {
87  return QSize(ext, ext);
88 }
89 
91 
92 #endif // QT_NO_TOOLBUTTON
QSize sizeHint() const
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void init(const QWidget *w)
Use initFrom(widget) instead.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void setCheckable(bool)
The QStyleOptionToolButton class is used to describe the parameters for drawing a tool button...
Definition: qstyleoption.h:768
QStyle * style() const
Definition: qwidget.cpp:2742
void setObjectName(const QString &name)
Definition: qobject.cpp:1112
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
The QStyleOption class stores the parameters used by QStyle functions.
Definition: qstyleoption.h:67
ToolButtonFeatures features
an OR combination of the tool button&#39;s features
Definition: qstyleoption.h:778
void setAutoRaise(bool enable)
void initStyleOption(QStyleOptionToolButton *option) const
Initialize option with the values from this QToolButton.
The QStylePainter class is a convenience class for drawing QStyle elements inside a widget...
Definition: qstylepainter.h:55
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
void paintEvent(QPaintEvent *)
Reimplemented Function
The QToolButton class provides a quick-access button to commands or options, usually used inside a QT...
Definition: qtoolbutton.h:59
void drawComplexControl(QStyle::ComplexControl cc, const QStyleOptionComplex &opt)
Use the widget&#39;s style to draw a complex control cc specified by the QStyleOptionComplex option...
Definition: qstylepainter.h:92
void setOrientation(Qt::Orientation o)
The QPaintEvent class contains event parameters for paint events.
Definition: qevent.h:298
void setSizePolicy(QSizePolicy)
Definition: qwidget.cpp:10198
void setIcon(const QIcon &icon)
Orientation
Definition: qnamespace.h:174
QToolBarExtension(QWidget *parent)