Qt 4.8
qtoolbox.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 "qtoolbox.h"
43 
44 #ifndef QT_NO_TOOLBOX
45 
46 #include <qapplication.h>
47 #include <qeventloop.h>
48 #include <qlayout.h>
49 #include <qlist.h>
50 #include <qpainter.h>
51 #include <qscrollarea.h>
52 #include <qstyle.h>
53 #include <qstyleoption.h>
54 #include <qtooltip.h>
55 #include <qabstractbutton.h>
56 
57 #include "qframe_p.h"
58 
60 
62 {
63  Q_OBJECT
64 public:
66  : QAbstractButton(parent), selected(false), indexInPage(-1)
67  {
71  }
72 
73  inline void setSelected(bool b) { selected = b; update(); }
74  inline void setIndex(int newIndex) { indexInPage = newIndex; }
75 
76  QSize sizeHint() const;
77  QSize minimumSizeHint() const;
78 
79 protected:
80  void initStyleOption(QStyleOptionToolBox *opt) const;
81  void paintEvent(QPaintEvent *);
82 
83 private:
84  bool selected;
86 };
87 
88 
90 {
92 public:
93  struct Page
94  {
98 
99  inline void setText(const QString &text) { button->setText(text); }
100  inline void setIcon(const QIcon &is) { button->setIcon(is); }
101 #ifndef QT_NO_TOOLTIP
102  inline void setToolTip(const QString &tip) { button->setToolTip(tip); }
103  inline QString toolTip() const { return button->toolTip(); }
104 #endif
105  inline QString text() const { return button->text(); }
106  inline QIcon icon() const { return button->icon(); }
107 
108  inline bool operator==(const Page& other) const
109  {
110  return widget == other.widget;
111  }
112  };
114 
116  : currentPage(0)
117  {
118  }
119  void _q_buttonClicked();
120  void _q_widgetDestroyed(QObject*);
121 
122  Page *page(QWidget *widget) const;
123  const Page *page(int index) const;
124  Page *page(int index);
125 
126  void updateTabs();
127  void relayout();
128 
129  PageList pageList;
132 };
133 
135 {
136  if (!widget)
137  return 0;
138 
139  for (PageList::ConstIterator i = pageList.constBegin(); i != pageList.constEnd(); ++i)
140  if ((*i).widget == widget)
141  return (Page*) &(*i);
142  return 0;
143 }
144 
146 {
147  if (index >= 0 && index < pageList.size())
148  return &pageList[index];
149  return 0;
150 }
151 
153 {
154  if (index >= 0 && index < pageList.size())
155  return &pageList.at(index);
156  return 0;
157 }
158 
160 {
161  QToolBoxButton *lastButton = currentPage ? currentPage->button : 0;
162  bool after = false;
163  int index = 0;
164  for (index = 0; index < pageList.count(); ++index) {
165  const Page &page = pageList.at(index);
166  QToolBoxButton *tB = page.button;
167  // update indexes, since the updates are delayed, the indexes will be correct
168  // when we actually paint.
169  tB->setIndex(index);
170  QWidget *tW = page.widget;
171  if (after) {
172  QPalette p = tB->palette();
173  p.setColor(tB->backgroundRole(), tW->palette().color(tW->backgroundRole()));
174  tB->setPalette(p);
175  tB->update();
176  } else if (tB->backgroundRole() != QPalette::Window) {
178  tB->update();
179  }
180  after = tB == lastButton;
181  }
182 }
183 
185 {
186  QSize iconSize(8, 8);
187  if (!icon().isNull()) {
188  int icone = style()->pixelMetric(QStyle::PM_SmallIconSize, 0, parentWidget() /* QToolBox */);
189  iconSize += QSize(icone + 2, icone);
190  }
191  QSize textSize = fontMetrics().size(Qt::TextShowMnemonic, text()) + QSize(0, 8);
192 
193  QSize total(iconSize.width() + textSize.width(), qMax(iconSize.height(), textSize.height()));
194  return total.expandedTo(QApplication::globalStrut());
195 }
196 
198 {
199  if (icon().isNull())
200  return QSize();
201  int icone = style()->pixelMetric(QStyle::PM_SmallIconSize, 0, parentWidget() /* QToolBox */);
202  return QSize(icone + 8, icone + 8);
203 }
204 
206 {
207  if (!option)
208  return;
209  option->initFrom(this);
210  if (selected)
211  option->state |= QStyle::State_Selected;
212  if (isDown())
213  option->state |= QStyle::State_Sunken;
214  option->text = text();
215  option->icon = icon();
216 
217  if (QStyleOptionToolBoxV2 *optionV2 = qstyleoption_cast<QStyleOptionToolBoxV2 *>(option)) {
218  QToolBox *toolBox = static_cast<QToolBox *>(parentWidget()); // I know I'm in a tool box.
219  int widgetCount = toolBox->count();
220  int currIndex = toolBox->currentIndex();
221  if (widgetCount == 1) {
222  optionV2->position = QStyleOptionToolBoxV2::OnlyOneTab;
223  } else if (indexInPage == 0) {
224  optionV2->position = QStyleOptionToolBoxV2::Beginning;
225  } else if (indexInPage == widgetCount - 1) {
226  optionV2->position = QStyleOptionToolBoxV2::End;
227  } else {
228  optionV2->position = QStyleOptionToolBoxV2::Middle;
229  }
230  if (currIndex == indexInPage - 1) {
231  optionV2->selectedPosition = QStyleOptionToolBoxV2::PreviousIsSelected;
232  } else if (currIndex == indexInPage + 1) {
233  optionV2->selectedPosition = QStyleOptionToolBoxV2::NextIsSelected;
234  } else {
235  optionV2->selectedPosition = QStyleOptionToolBoxV2::NotAdjacent;
236  }
237  }
238 }
239 
241 {
242  QPainter paint(this);
244  QPainter *p = &paint;
246  initStyleOption(&opt);
248 }
249 
300 #ifdef QT3_SUPPORT
301 
304 QToolBox::QToolBox(QWidget *parent, const char *name, Qt::WindowFlags f)
305  : QFrame(*new QToolBoxPrivate, parent, f)
306 {
307  Q_D(QToolBox);
309  d->layout = new QVBoxLayout(this);
310  d->layout->setMargin(0);
312 }
313 #endif
314 
318 QToolBox::QToolBox(QWidget *parent, Qt::WindowFlags f)
319  : QFrame(*new QToolBoxPrivate, parent, f)
320 {
321  Q_D(QToolBox);
322  d->layout = new QVBoxLayout(this);
323  d->layout->setMargin(0);
325 }
326 
332 {
333 }
334 
366 int QToolBox::insertItem(int index, QWidget *widget, const QIcon &icon, const QString &text)
367 {
368  if (!widget)
369  return -1;
370 
371  Q_D(QToolBox);
372  connect(widget, SIGNAL(destroyed(QObject*)), this, SLOT(_q_widgetDestroyed(QObject*)));
373 
375  c.widget = widget;
376  c.button = new QToolBoxButton(this);
377  c.button->setObjectName(QLatin1String("qt_toolbox_toolboxbutton"));
378  connect(c.button, SIGNAL(clicked()), this, SLOT(_q_buttonClicked()));
379 
380  c.sv = new QScrollArea(this);
381  c.sv->setWidget(widget);
382  c.sv->setWidgetResizable(true);
383  c.sv->hide();
385 
386  c.setText(text);
387  c.setIcon(icon);
388 
389  if (index < 0 || index >= (int)d->pageList.count()) {
390  index = d->pageList.count();
391  d->pageList.append(c);
392  d->layout->addWidget(c.button);
393  d->layout->addWidget(c.sv);
394  if (index == 0)
395  setCurrentIndex(index);
396  } else {
397  d->pageList.insert(index, c);
398  d->relayout();
399  if (d->currentPage) {
400  QWidget *current = d->currentPage->widget;
401  int oldindex = indexOf(current);
402  if (index <= oldindex) {
403  d->currentPage = 0; // trigger change
404  setCurrentIndex(oldindex);
405  }
406  }
407  }
408 
409  c.button->show();
410 
411  d->updateTabs();
412  itemInserted(index);
413  return index;
414 }
415 
417 {
418  Q_Q(QToolBox);
419  QToolBoxButton *tb = qobject_cast<QToolBoxButton*>(q->sender());
420  QWidget* item = 0;
421  for (QToolBoxPrivate::PageList::ConstIterator i = pageList.constBegin(); i != pageList.constEnd(); ++i)
422  if ((*i).button == tb) {
423  item = (*i).widget;
424  break;
425  }
426 
427  q->setCurrentIndex(q->indexOf(item));
428 }
429 
440 int QToolBox::count() const
441 {
442  Q_D(const QToolBox);
443  return d->pageList.count();
444 }
445 
447 {
448  Q_D(QToolBox);
449  QToolBoxPrivate::Page *c = d->page(index);
450  if (!c || d->currentPage == c)
451  return;
452 
453  c->button->setSelected(true);
454  if (d->currentPage) {
455  d->currentPage->sv->hide();
456  d->currentPage->button->setSelected(false);
457  }
458  d->currentPage = c;
459  d->currentPage->sv->show();
460  d->updateTabs();
461  emit currentChanged(index);
462 }
463 
465 {
466  Q_Q(QToolBox);
467  delete layout;
468  layout = new QVBoxLayout(q);
469  layout->setMargin(0);
470  for (QToolBoxPrivate::PageList::ConstIterator i = pageList.constBegin(); i != pageList.constEnd(); ++i) {
471  layout->addWidget((*i).button);
472  layout->addWidget((*i).sv);
473  }
474 }
475 
477 {
478  Q_Q(QToolBox);
479  // no verification - vtbl corrupted already
480  QWidget *p = (QWidget*)object;
481 
482  QToolBoxPrivate::Page *c = page(p);
483  if (!p || !c)
484  return;
485 
486  layout->removeWidget(c->sv);
488  c->sv->deleteLater(); // page might still be a child of sv
489  delete c->button;
490 
491  bool removeCurrent = c == currentPage;
492  pageList.removeAll(*c);
493 
494  if (!pageList.count()) {
495  currentPage = 0;
496  emit q->currentChanged(-1);
497  } else if (removeCurrent) {
498  currentPage = 0;
499  q->setCurrentIndex(0);
500  }
501 }
502 
509 {
510  Q_D(QToolBox);
511  if (QWidget *w = widget(index)) {
512  disconnect(w, SIGNAL(destroyed(QObject*)), this, SLOT(_q_widgetDestroyed(QObject*)));
513  w->setParent(this);
514  // destroy internal data
515  d->_q_widgetDestroyed(w);
516  itemRemoved(index);
517  }
518 }
519 
520 
534 int QToolBox::currentIndex() const
535 {
536  Q_D(const QToolBox);
537  return d->currentPage ? indexOf(d->currentPage->widget) : -1;
538 }
539 
547 {
548  Q_D(const QToolBox);
549  return d->currentPage ? d->currentPage->widget : 0;
550 }
551 
558 {
559  int i = indexOf(widget);
560  if (i >= 0)
561  setCurrentIndex(i);
562  else
563  qWarning("QToolBox::setCurrentWidget: widget not contained in tool box");
564 }
565 
572 {
573  Q_D(const QToolBox);
574  if (index < 0 || index >= (int) d->pageList.size())
575  return 0;
576  return d->pageList.at(index).widget;
577 }
578 
585 {
586  Q_D(const QToolBox);
587  QToolBoxPrivate::Page *c = (widget ? d->page(widget) : 0);
588  return c ? d->pageList.indexOf(*c) : -1;
589 }
590 
597 {
598  Q_D(QToolBox);
599  QToolBoxPrivate::Page *c = d->page(index);
600  if (!c)
601  return;
602 
603  c->button->setEnabled(enabled);
604  if (!enabled && c == d->currentPage) {
605  int curIndexUp = index;
606  int curIndexDown = curIndexUp;
607  const int count = d->pageList.count();
608  while (curIndexUp > 0 || curIndexDown < count-1) {
609  if (curIndexDown < count-1) {
610  if (d->page(++curIndexDown)->button->isEnabled()) {
611  index = curIndexDown;
612  break;
613  }
614  }
615  if (curIndexUp > 0) {
616  if (d->page(--curIndexUp)->button->isEnabled()) {
617  index = curIndexUp;
618  break;
619  }
620  }
621  }
622  setCurrentIndex(index);
623  }
624 }
625 
626 
640 {
641  Q_D(QToolBox);
642  QToolBoxPrivate::Page *c = d->page(index);
643  if (c)
644  c->setText(text);
645 }
646 
651 void QToolBox::setItemIcon(int index, const QIcon &icon)
652 {
653  Q_D(QToolBox);
654  QToolBoxPrivate::Page *c = d->page(index);
655  if (c)
656  c->setIcon(icon);
657 }
658 
659 #ifndef QT_NO_TOOLTIP
660 
665 {
666  Q_D(QToolBox);
667  QToolBoxPrivate::Page *c = d->page(index);
668  if (c)
669  c->setToolTip(toolTip);
670 }
671 #endif // QT_NO_TOOLTIP
672 
678 {
679  Q_D(const QToolBox);
680  const QToolBoxPrivate::Page *c = d->page(index);
681  return c && c->button->isEnabled();
682 }
683 
690 {
691  Q_D(const QToolBox);
692  const QToolBoxPrivate::Page *c = d->page(index);
693  return (c ? c->text() : QString());
694 }
695 
702 {
703  Q_D(const QToolBox);
704  const QToolBoxPrivate::Page *c = d->page(index);
705  return (c ? c->icon() : QIcon());
706 }
707 
708 #ifndef QT_NO_TOOLTIP
709 
715 {
716  Q_D(const QToolBox);
717  const QToolBoxPrivate::Page *c = d->page(index);
718  return (c ? c->toolTip() : QString());
719 }
720 #endif // QT_NO_TOOLTIP
721 
724 {
726 }
727 
730 {
731  Q_D(QToolBox);
732  if(ev->type() == QEvent::StyleChange)
733  d->updateTabs();
735 }
736 
744 {
745  Q_UNUSED(index)
746 }
747 
755 {
756  Q_UNUSED(index)
757 }
758 
843 {
844  return QFrame::event(e);
845 }
846 
848 
849 #include "moc_qtoolbox.cpp"
850 #include "qtoolbox.moc"
851 
852 #endif //QT_NO_TOOLBOX
The QAbstractButton class is the abstract base class of button widgets, providing functionality commo...
void updateTabs()
Definition: qtoolbox.cpp:159
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
double d
Definition: qnumeric_p.h:62
QIcon itemIcon(int index) const
Returns the icon of the item at position index, or a null icon if index is out of range...
Definition: qtoolbox.cpp:701
bool enabled
whether the widget is enabled
Definition: qwidget.h:157
QToolBoxButton(QWidget *parent)
Definition: qtoolbox.cpp:65
QPalette palette
the widget&#39;s palette
Definition: qwidget.h:180
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
QList< Page > PageList
Definition: qtoolbox.cpp:113
The QStyleOptionToolBoxV2 class is used to describe the parameters necessary for drawing a frame in Q...
Definition: qstyleoption.h:649
virtual void showEvent(QShowEvent *)
This event handler can be reimplemented in a subclass to receive widget show events which are passed ...
Definition: qwidget.cpp:9842
The QToolBox class provides a column of tabbed widget items.
Definition: qtoolbox.h:58
QString text
the text for the tool box tab
Definition: qstyleoption.h:639
unsigned char c[8]
Definition: qnumeric_p.h:62
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QString text() const
void setText(const QString &text)
QString itemText(int index) const
Returns the text of the item at position index, or an empty string if index is out of range...
Definition: qtoolbox.cpp:689
QPointer< QWidget > widget
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276
int count() const
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
static QSize globalStrut()
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
#define SLOT(a)
Definition: qobjectdefs.h:226
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
bool isDown() const
QSize expandedTo(const QSize &) const
Returns a size holding the maximum width and height of this size and the given otherSize.
Definition: qsize.h:187
QPalette::ColorRole backgroundRole() const
Returns the background role of the widget.
Definition: qwidget.cpp:4677
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void setItemText(int index, const QString &text)
Sets the text of the item at position index to text.
Definition: qtoolbox.cpp:639
QSize sizeHint() const
Definition: qtoolbox.cpp:184
The QString class provides a Unicode character string.
Definition: qstring.h:83
T * qobject_cast(QObject *object)
Definition: qobject.h:375
The QStyleOptionToolBox class is used to describe the parameters needed for drawing a tool box...
Definition: qstyleoption.h:633
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define Q_D(Class)
Definition: qglobal.h:2482
const QColor & color(ColorGroup cg, ColorRole cr) const
Returns the color in the specified color group, used for the given color role.
Definition: qpalette.h:107
Page * page(QWidget *widget) const
Definition: qtoolbox.cpp:134
The QScrollArea class provides a scrolling view onto another widget.
Definition: qscrollarea.h:57
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
QScrollArea * sv
Definition: qtoolbox.cpp:96
QStyle * style() const
Definition: qwidget.cpp:2742
void setObjectName(const QString &name)
Definition: qobject.cpp:1112
#define Q_Q(Class)
Definition: qglobal.h:2483
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
void setWidgetResizable(bool resizable)
#define SIGNAL(a)
Definition: qobjectdefs.h:227
QIcon icon() const
Definition: qtoolbox.cpp:106
int width() const
Returns the width.
Definition: qsize.h:126
QString text() const
Definition: qtoolbox.cpp:105
void setBackgroundRole(QPalette::ColorRole)
Sets the background role of the widget to role.
Definition: qwidget.cpp:4708
QWidget * widget(int index) const
Returns the widget at position index, or 0 if there is no such item.
Definition: qtoolbox.cpp:571
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
void setIcon(const QIcon &is)
Definition: qtoolbox.cpp:100
void destroyed(QObject *=0)
This signal is emitted immediately before the object obj is destroyed, and can not be blocked...
QSize minimumSizeHint() const
Definition: qtoolbox.cpp:197
void changeEvent(QEvent *)
This event handler can be reimplemented to handle state changes.
Definition: qframe.cpp:574
QSize size(int flags, const QString &str, int tabstops=0, int *tabarray=0) const
Returns the size in pixels of text.
void removeItem(int index)
Removes the item at position index from the toolbox.
Definition: qtoolbox.cpp:508
void setItemToolTip(int index, const QString &toolTip)
Sets the tooltip of the item at position index to toolTip.
Definition: qtoolbox.cpp:664
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
void initFrom(const QWidget *w)
Definition: qstyleoption.h:99
QIcon icon
the icon for the tool box tab
Definition: qstyleoption.h:640
const char * name
void initStyleOption(QStyleOptionToolBox *opt) const
Definition: qtoolbox.cpp:205
void currentChanged(int index)
This signal is emitted when the current item is changed.
int currentIndex() const
#define emit
Definition: qobjectdefs.h:76
const QPalette & palette() const
QFontMetrics fontMetrics() const
Returns the font metrics for the widget&#39;s current font.
Definition: qwidget.h:984
Q_CORE_EXPORT void qWarning(const char *,...)
int indexOf(QWidget *widget) const
Returns the index of widget, or -1 if the item does not exist.
Definition: qtoolbox.cpp:584
void setCurrentWidget(QWidget *widget)
Makeswidget the current widget.
Definition: qtoolbox.cpp:557
void show()
Shows the widget and its child widgets.
The QShowEvent class provides an event that is sent when a widget is shown.
Definition: qevent.h:380
void showEvent(QShowEvent *e)
Reimplemented Function
Definition: qtoolbox.cpp:723
void setEnabled(bool)
Definition: qwidget.cpp:3447
void setText(const QString &text)
Definition: qtoolbox.cpp:99
#define Q_OBJECT
Definition: qobjectdefs.h:157
bool isEnabled() const
Definition: qwidget.h:948
void hide()
Hides the widget.
Definition: qwidget.h:501
void setToolTip(const QString &)
Definition: qwidget.cpp:11600
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
Definition: qobject.cpp:2895
QSize iconSize() const
QVBoxLayout * layout
Definition: qtoolbox.cpp:130
void setCurrentIndex(int index)
Definition: qtoolbox.cpp:446
#define Q_DECLARE_PUBLIC(Class)
Definition: qglobal.h:2477
QString toolTip() const
QToolBox(QWidget *parent=0, Qt::WindowFlags f=0)
Constructs a new toolbox with the given parent and the flags, f.
Definition: qtoolbox.cpp:318
void addWidget(QWidget *w)
Adds widget w to this layout in a manner specific to the layout.
Definition: qlayout.cpp:319
void setToolTip(const QString &tip)
Definition: qtoolbox.cpp:102
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
QWidget * currentWidget() const
Returns a pointer to the current widget, or 0 if there is no such item.
Definition: qtoolbox.cpp:546
const_iterator ConstIterator
Qt-style synonym for QList::const_iterator.
Definition: qlist.h:279
void setColor(ColorGroup cg, ColorRole cr, const QColor &color)
Sets the color in the specified color group, used for the given color role, to the specified solid co...
Definition: qpalette.h:201
void setFrameStyle(int)
Sets the frame style to style.
Definition: qframe.cpp:329
bool event(QEvent *e)
Reimplemented Function
Definition: qframe.cpp:587
virtual void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const =0
Draws the given element with the provided painter with the style options specified by option...
QString itemToolTip(int index) const
Returns the tooltip of the item at position index, or an empty string if index is out of range...
Definition: qtoolbox.cpp:714
int height() const
Returns the height.
Definition: qsize.h:129
int insertItem(int index, QWidget *widget, const QString &text)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qtoolbox.h:139
int count
The number of items contained in the toolbox.
Definition: qtoolbox.h:62
virtual void itemInserted(int index)
This virtual handler is called after a new item was added or inserted at position index...
Definition: qtoolbox.cpp:743
bool event(QEvent *e)
Reimplemented Function
Definition: qtoolbox.cpp:842
void setWidget(QWidget *widget)
Sets the scroll area&#39;s widget.
Page * currentPage
Definition: qtoolbox.cpp:131
void changeEvent(QEvent *)
Reimplemented Function
Definition: qtoolbox.cpp:729
quint16 index
void setItemIcon(int index, const QIcon &icon)
Sets the icon of the item at position index to icon.
Definition: qtoolbox.cpp:651
void setSelected(bool b)
Definition: qtoolbox.cpp:73
virtual void itemRemoved(int index)
This virtual handler is called after an item was removed from position index.
Definition: qtoolbox.cpp:754
QLayout * layout() const
Returns the layout manager that is installed on this widget, or 0 if no layout manager is installed...
Definition: qwidget.cpp:10073
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
PageList pageList
Definition: qtoolbox.cpp:129
The QVBoxLayout class lines up widgets vertically.
Definition: qboxlayout.h:149
void paintEvent(QPaintEvent *)
Reimplemented Function
Definition: qtoolbox.cpp:240
void setItemEnabled(int index, bool enabled)
If enabled is true then the item at position index is enabled; otherwise the item at position index i...
Definition: qtoolbox.cpp:596
int currentIndex
the index of the current item
Definition: qtoolbox.h:61
void _q_buttonClicked()
Definition: qtoolbox.cpp:416
void setIndex(int newIndex)
Definition: qtoolbox.cpp:74
The QPaintEvent class contains event parameters for paint events.
Definition: qevent.h:298
void setSizePolicy(QSizePolicy)
Definition: qwidget.cpp:10198
void setMargin(int)
Definition: qlayout.cpp:464
void setIcon(const QIcon &icon)
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
void _q_widgetDestroyed(QObject *)
Definition: qtoolbox.cpp:476
The QFrame class is the base class of widgets that can have a frame.
Definition: qframe.h:55
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
QString toolTip() const
Definition: qtoolbox.cpp:103
bool operator==(const Page &other) const
Definition: qtoolbox.cpp:108
void deleteLater()
Schedules this object for deletion.
Definition: qobject.cpp:2145
void setPalette(const QPalette &)
Use the single-argument overload instead.
Definition: qwidget.cpp:4858
~QToolBox()
Destroys the toolbox.
Definition: qtoolbox.cpp:331
static bool isNull(const QVariant::Private *d)
Definition: qvariant.cpp:300
void removeWidget(QWidget *w)
Removes the widget widget from the layout.
Definition: qlayout.cpp:1516
#define text
Definition: qobjectdefs.h:80
QIcon icon() const
void setFocusPolicy(Qt::FocusPolicy policy)
Definition: qwidget.cpp:7631
QToolBoxButton * button
Definition: qtoolbox.cpp:95
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61
bool isItemEnabled(int index) const
Returns true if the item at position index is enabled; otherwise returns false.
Definition: qtoolbox.cpp:677
The QIcon class provides scalable icons in different modes and states.
Definition: qicon.h:60