Qt 4.8
qgroupbox.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 "qgroupbox.h"
43 #ifndef QT_NO_GROUPBOX
44 #include "qapplication.h"
45 #include "qbitmap.h"
46 #include "qdrawutil.h"
47 #include "qevent.h"
48 #include "qlayout.h"
49 #include "qradiobutton.h"
50 #include "qstyle.h"
51 #include "qstyleoption.h"
52 #include "qstylepainter.h"
53 #ifndef QT_NO_ACCESSIBILITY
54 #include "qaccessible.h"
55 #endif
56 #include <private/qwidget_p.h>
57 
58 #include "qdebug.h"
59 
61 
63 {
65 
66 public:
67  void skip();
68  void init();
69  void calculateFrame();
71  int align;
72 #ifndef QT_NO_SHORTCUT
74 #endif
75 
76  void _q_fixFocus(Qt::FocusReason reason);
77  void _q_setChildrenEnabled(bool b);
78  void click();
79  bool flat;
80  bool checkable;
81  bool checked;
82  bool hover;
85 };
86 
95 {
96  if (!option)
97  return;
98 
99  Q_D(const QGroupBox);
100  option->initFrom(this);
101  option->text = d->title;
102  option->lineWidth = 1;
103  option->midLineWidth = 0;
104  option->textAlignment = Qt::Alignment(d->align);
105  option->activeSubControls |= d->pressedControl;
107 
108  if (d->hover)
109  option->state |= QStyle::State_MouseOver;
110  else
111  option->state &= ~QStyle::State_MouseOver;
112 
113  if (d->flat)
115 
116  if (d->checkable) {
118  option->state |= (d->checked ? QStyle::State_On : QStyle::State_Off);
119  if ((d->pressedControl == QStyle::SC_GroupBoxCheckBox
120  || d->pressedControl == QStyle::SC_GroupBoxLabel) && (d->hover || d->overCheckBox))
121  option->state |= QStyle::State_Sunken;
122  }
123 
124  if (!option->palette.isBrushSet(isEnabled() ? QPalette::Active :
126  option->textColor = QColor(style()->styleHint(QStyle::SH_GroupBox_TextLabelColor,
127  option, this));
128 
129  if (!d->title.isEmpty())
131 }
132 
134 {
135  Q_Q(QGroupBox);
136 
137  QPointer<QGroupBox> guard(q);
138  q->setChecked(!checked);
139  if (!guard)
140  return;
141  emit q->clicked(checked);
142 }
143 
195  : QWidget(*new QGroupBoxPrivate, parent, 0)
196 {
197  Q_D(QGroupBox);
198  d->init();
199 }
200 
206  : QWidget(*new QGroupBoxPrivate, parent, 0)
207 {
208  Q_D(QGroupBox);
209  d->init();
210  setTitle(title);
211 }
212 
213 
218 {
219 }
220 
222 {
223  Q_Q(QGroupBox);
224  align = Qt::AlignLeft;
225 #ifndef QT_NO_SHORTCUT
226  shortcutId = 0;
227 #endif
228  flat = false;
229  checkable = false;
230  checked = true;
231  hover = false;
232  overCheckBox = false;
233  pressedControl = QStyle::SC_None;
234  calculateFrame();
237 }
238 
240 {
241  Q_D(QGroupBox);
242  if (d->title == title) // no change
243  return;
244  d->title = title;
245 #ifndef QT_NO_SHORTCUT
246  releaseShortcut(d->shortcutId);
247  d->shortcutId = grabShortcut(QKeySequence::mnemonic(title));
248 #endif
249  d->calculateFrame();
250 
251  update();
252  updateGeometry();
253 #ifndef QT_NO_ACCESSIBILITY
255 #endif
256 }
257 
281 {
282  Q_D(const QGroupBox);
283  return d->title;
284 }
285 
307 Qt::Alignment QGroupBox::alignment() const
308 {
309  Q_D(const QGroupBox);
310  return QFlag(d->align);
311 }
312 
314 {
315  Q_D(QGroupBox);
316  d->align = alignment;
317  updateGeometry();
318  update();
319 }
320 
324 {
326 }
327 
332 {
333  QStylePainter paint(this);
334  QStyleOptionGroupBox option;
335  initStyleOption(&option);
337 }
338 
341 {
342  Q_D(QGroupBox);
343 #ifndef QT_NO_SHORTCUT
344  if (e->type() == QEvent::Shortcut) {
345  QShortcutEvent *se = static_cast<QShortcutEvent *>(e);
346  if (se->shortcutId() == d->shortcutId) {
347  if (!isCheckable()) {
348  d->_q_fixFocus(Qt::ShortcutFocusReason);
349  } else {
350  d->click();
352  }
353  return true;
354  }
355  }
356 #endif
358  initStyleOption(&box);
359  switch (e->type()) {
360  case QEvent::HoverEnter:
361  case QEvent::HoverMove: {
363  static_cast<QHoverEvent *>(e)->pos(),
364  this);
365  bool oldHover = d->hover;
366  d->hover = d->checkable && (control == QStyle::SC_GroupBoxLabel || control == QStyle::SC_GroupBoxCheckBox);
367  if (oldHover != d->hover) {
370  update(rect);
371  }
372  return true;
373  }
374  case QEvent::HoverLeave:
375  d->hover = false;
376  if (d->checkable) {
379  update(rect);
380  }
381  return true;
382  case QEvent::KeyPress: {
383  QKeyEvent *k = static_cast<QKeyEvent*>(e);
384  if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
385  d->pressedControl = QStyle::SC_GroupBoxCheckBox;
386  update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this));
387  return true;
388  }
389  break;
390  }
391  case QEvent::KeyRelease: {
392  QKeyEvent *k = static_cast<QKeyEvent*>(e);
393  if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
394  bool toggle = (d->pressedControl == QStyle::SC_GroupBoxLabel
395  || d->pressedControl == QStyle::SC_GroupBoxCheckBox);
396  d->pressedControl = QStyle::SC_None;
397  if (toggle)
398  d->click();
399  return true;
400  }
401  break;
402  }
403  default:
404  break;
405  }
406  return QWidget::event(e);
407 }
408 
411 {
412  Q_D(QGroupBox);
413  if (c->type() != QEvent::ChildAdded || !c->child()->isWidgetType())
414  return;
415  QWidget *w = (QWidget*)c->child();
416  if (d->checkable) {
417  if (d->checked) {
419  w->setEnabled(true);
420  } else {
421  if (w->isEnabled()) {
422  w->setEnabled(false);
424  }
425  }
426  }
427 }
428 
429 
441 {
442  Q_Q(QGroupBox);
443  QWidget *fw = q->focusWidget();
444  if (!fw || fw == q) {
445  QWidget * best = 0;
446  QWidget * candidate = 0;
447  QWidget * w = q;
448  while ((w = w->nextInFocusChain()) != q) {
449  if (q->isAncestorOf(w) && (w->focusPolicy() & Qt::TabFocus) == Qt::TabFocus && w->isVisibleTo(q)) {
450  if (!best && qobject_cast<QRadioButton*>(w) && ((QRadioButton*)w)->isChecked())
451  // we prefer a checked radio button or a widget that
452  // already has focus, if there is one
453  best = w;
454  else
455  if (!candidate)
456  // but we'll accept anything that takes focus
457  candidate = w;
458  }
459  }
460  if (best)
461  fw = best;
462  else if (candidate)
463  fw = candidate;
464  }
465  if (fw)
466  fw->setFocus(reason);
467 }
468 
469 /*
470  Sets the right frame rect depending on the title.
471 */
473 {
474  Q_Q(QGroupBox);
476  q->initStyleOption(&box);
477  QRect contentsRect = q->style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxContents, q);
478  q->setContentsMargins(contentsRect.left() - box.rect.left(), contentsRect.top() - box.rect.top(),
479  box.rect.right() - contentsRect.right(), box.rect.bottom() - contentsRect.bottom());
481 }
482 
486 { // note no call to super
487  Q_D(QGroupBox);
488  if (focusPolicy() == Qt::NoFocus) {
489  d->_q_fixFocus(fe->reason());
490  } else {
492  }
493 }
494 
495 
500 {
501  Q_D(const QGroupBox);
502  QStyleOptionGroupBox option;
503  initStyleOption(&option);
504 
505  QFontMetrics metrics(fontMetrics());
506 
507  int baseWidth = metrics.width(d->title) + metrics.width(QLatin1Char(' '));
508  int baseHeight = metrics.height();
509  if (d->checkable) {
512  baseHeight = qMax(baseHeight, style()->pixelMetric(QStyle::PM_IndicatorHeight));
513  }
514 
515  QSize size = style()->sizeFromContents(QStyle::CT_GroupBox, &option, QSize(baseWidth, baseHeight), this);
516  return size.expandedTo(QWidget::minimumSizeHint());
517 }
518 
539 bool QGroupBox::isFlat() const
540 {
541  Q_D(const QGroupBox);
542  return d->flat;
543 }
544 
545 void QGroupBox::setFlat(bool b)
546 {
547  Q_D(QGroupBox);
548  if (d->flat == b)
549  return;
550  d->flat = b;
551  updateGeometry();
552  update();
553 }
554 
555 
576 {
577  Q_D(QGroupBox);
578 
579  bool wasCheckable = d->checkable;
580  d->checkable = checkable;
581 
582  if (checkable) {
583  setChecked(true);
584  if (!wasCheckable) {
586  d->_q_setChildrenEnabled(true);
587  updateGeometry();
588  }
589  } else {
590  if (wasCheckable) {
592  d->_q_setChildrenEnabled(true);
593  updateGeometry();
594  }
595  d->_q_setChildrenEnabled(true);
596  }
597 
598  if (wasCheckable != checkable) {
599  d->calculateFrame();
600  update();
601  }
602 }
603 
605 {
606  Q_D(const QGroupBox);
607  return d->checkable;
608 }
609 
610 
612 {
613  Q_D(const QGroupBox);
614  return d->checkable && d->checked;
615 }
616 
617 
665 {
666  Q_D(QGroupBox);
667  if (d->checkable && b != d->checked) {
668  update();
669  d->checked = b;
670  d->_q_setChildrenEnabled(b);
671 #ifndef QT_NO_ACCESSIBILITY
673 #endif
674  emit toggled(b);
675  }
676 }
677 
678 /*
679  sets all children of the group box except the qt_groupbox_checkbox
680  to either disabled/enabled
681 */
683 {
684  Q_Q(QGroupBox);
685  QObjectList childList = q->children();
686  for (int i = 0; i < childList.size(); ++i) {
687  QObject *o = childList.at(i);
688  if (o->isWidgetType()) {
689  QWidget *w = static_cast<QWidget *>(o);
690  if (b) {
692  w->setEnabled(true);
693  } else {
694  if (w->isEnabled()) {
695  w->setEnabled(false);
697  }
698  }
699  }
700  }
701 }
702 
705 {
706  Q_D(QGroupBox);
707  if (ev->type() == QEvent::EnabledChange) {
708  if (d->checkable && isEnabled()) {
709  // we are being enabled - disable children
710  if (!d->checked)
711  d->_q_setChildrenEnabled(false);
712  }
713  } else if (ev->type() == QEvent::FontChange
714 #ifdef Q_WS_MAC
715  || ev->type() == QEvent::MacSizeChange
716 #endif
717  || ev->type() == QEvent::StyleChange) {
718  d->calculateFrame();
719  }
721 }
722 
725 {
726  if (event->button() != Qt::LeftButton) {
727  event->ignore();
728  return;
729  }
730 
731  Q_D(QGroupBox);
733  initStyleOption(&box);
734  d->pressedControl = style()->hitTestComplexControl(QStyle::CC_GroupBox, &box,
735  event->pos(), this);
736  if (d->checkable && (d->pressedControl & (QStyle::SC_GroupBoxCheckBox | QStyle::SC_GroupBoxLabel))) {
737  d->overCheckBox = true;
738  update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this));
739  }
740 }
741 
744 {
745  Q_D(QGroupBox);
747  initStyleOption(&box);
749  event->pos(), this);
750  bool oldOverCheckBox = d->overCheckBox;
751  d->overCheckBox = (pressed == QStyle::SC_GroupBoxCheckBox || pressed == QStyle::SC_GroupBoxLabel);
752  if (d->checkable && (d->pressedControl == QStyle::SC_GroupBoxCheckBox || d->pressedControl == QStyle::SC_GroupBoxLabel)
753  && (d->overCheckBox != oldOverCheckBox))
754  update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this));
755 }
756 
759 {
760  if (event->button() != Qt::LeftButton) {
761  event->ignore();
762  return;
763  }
764 
765  Q_D(QGroupBox);
766  if (!d->overCheckBox) {
767  event->ignore();
768  return;
769  }
771  initStyleOption(&box);
773  event->pos(), this);
774  bool toggle = d->checkable && (released == QStyle::SC_GroupBoxLabel
775  || released == QStyle::SC_GroupBoxCheckBox);
776  d->pressedControl = QStyle::SC_None;
777  d->overCheckBox = false;
778  if (toggle)
779  d->click();
780  else if (d->checkable)
781  update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this));
782 }
783 
784 #ifdef QT3_SUPPORT
785 
790  : QWidget(*new QGroupBoxPrivate, parent, 0)
791 {
792  Q_D(QGroupBox);
794  d->init();
795 }
796 
801 QGroupBox::QGroupBox(const QString &title, QWidget *parent, const char *name)
802  : QWidget(*new QGroupBoxPrivate, parent, 0)
803 {
804  Q_D(QGroupBox);
806  d->init();
807  setTitle(title);
808 }
809 #endif // QT3_SUPPORT
810 
812 
813 #include "moc_qgroupbox.cpp"
814 
815 #endif //QT_NO_GROUPBOX
QPoint pos() const
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
double d
Definition: qnumeric_p.h:62
QString text
the text of the group box
Definition: qstyleoption.h:841
void setAlignment(int alignment)
Definition: qgroupbox.cpp:313
QString title() const
static void updateAccessibility(QObject *, int who, Event reason)
Notifies accessibility clients about a change in object&#39;s accessibility information.
int width(const QString &, int len=-1) const
Returns the width in pixels of the first len characters of text.
void initStyleOption(QStyleOptionGroupBox *option) const
Initialize option with the values from this QGroupBox.
Definition: qgroupbox.cpp:94
The QKeyEvent class describes a key event.
Definition: qevent.h:224
QWidget * focusWidget() const
Returns the last child of this widget that setFocus had been called on.
Definition: qwidget.cpp:6863
SubControl
This enum describes the available sub controls.
Definition: qstyle.h:402
bool event(QEvent *event)
Reimplemented Function
Definition: qgroupbox.cpp:340
unsigned char c[8]
Definition: qnumeric_p.h:62
The QFontMetrics class provides font metrics information.
Definition: qfontmetrics.h:65
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
void setChecked(bool checked)
Definition: qgroupbox.cpp:664
QSize size() const
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
bool flat
whether the group box is painted flat or has a frame
Definition: qgroupbox.h:63
bool isChecked() const
Definition: qgroupbox.cpp:611
virtual QSize minimumSizeHint() const
Qt::Alignment alignment() const
QGroupBox(QWidget *parent=0)
Constructs a group box widget with the given parent but with no title.
Definition: qgroupbox.cpp:194
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
The QFlag class is a helper data type for QFlags.
Definition: qglobal.h:2289
QRect contentsRect() const
Returns the area inside the widget&#39;s margins.
Definition: qwidget.cpp:7544
void calculateFrame()
Definition: qgroupbox.cpp:472
virtual QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget=0) const =0
Returns the rectangle containing the specified subControl of the given complex control (with the styl...
bool isVisibleTo(QWidget *) const
Returns true if this widget would become visible if ancestor is shown; otherwise returns false...
Definition: qwidget.cpp:8371
bool isFlat() const
Definition: qgroupbox.cpp:539
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
static QKeySequence mnemonic(const QString &text)
Returns the shortcut key sequence for the mnemonic in text, or an empty key sequence if no mnemonics ...
QStyleOptionFrameV2::FrameFeatures features
the features of the group box frame
Definition: qstyleoption.h:840
Qt::FocusPolicy focusPolicy
the way the widget accepts keyboard focus
Definition: qwidget.h:187
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void _q_setChildrenEnabled(bool b)
Definition: qgroupbox.cpp:682
The QShortcutEvent class provides an event which is generated when the user presses a key combination...
Definition: qevent.h:675
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
bool checked
whether the group box is checked
Definition: qgroupbox.h:65
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
void changeEvent(QEvent *event)
Reimplemented Function
Definition: qgroupbox.cpp:704
virtual void resizeEvent(QResizeEvent *)
This event handler can be reimplemented in a subclass to receive widget resize events which are passe...
Definition: qwidget.cpp:9587
QWidget * nextInFocusChain() const
Returns the next widget in this widget&#39;s focus chain.
Definition: qwidget.cpp:6873
QStyle::SubControls activeSubControls
This variable holds a bitwise OR of the sub-controls that are active for the complex control...
Definition: qstyleoption.h:694
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
The QString class provides a Unicode character string.
Definition: qstring.h:83
Qt::Alignment textAlignment
the alignment of the group box title
Definition: qstyleoption.h:842
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define Q_D(Class)
Definition: qglobal.h:2482
Qt::FocusPolicy focusPolicy() const
The QPointer class is a template class that provides guarded pointers to QObject. ...
Definition: qpointer.h:54
void releaseShortcut(int id)
Removes the shortcut with the given id from Qt&#39;s shortcut system.
Definition: qwidget.cpp:11771
void mouseReleaseEvent(QMouseEvent *event)
Reimplemented Function
Definition: qgroupbox.cpp:758
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
const QPoint & pos() const
Returns the position of the mouse cursor, relative to the widget that received the event...
Definition: qevent.h:95
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 focusInEvent(QFocusEvent *event)
Reimplemented Function
Definition: qgroupbox.cpp:485
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
int key() const
Returns the code of the key that was pressed or released.
Definition: qevent.h:231
void _q_fixFocus(Qt::FocusReason reason)
This private slot finds a widget in this group box that can accept focus, and gives the focus to that...
Definition: qgroupbox.cpp:440
The QRadioButton widget provides a radio button with a text label.
Definition: qradiobutton.h:56
void setCheckable(bool checkable)
Definition: qgroupbox.cpp:575
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
void toggled(bool)
If the group box is checkable, this signal is emitted when the check box is toggled.
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
void childEvent(QChildEvent *event)
This event handler can be reimplemented in a subclass to receive child events.
Definition: qgroupbox.cpp:410
QWidget(QWidget *parent=0, Qt::WindowFlags f=0)
Constructs a widget which is a child of parent, with widget flags set to f.
Definition: qwidget.cpp:1189
void initFrom(const QWidget *w)
Definition: qstyleoption.h:99
const char * name
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
#define emit
Definition: qobjectdefs.h:76
virtual void changeEvent(QEvent *)
This event handler can be reimplemented to handle state changes.
Definition: qwidget.cpp:9170
QFontMetrics fontMetrics() const
Returns the font metrics for the widget&#39;s current font.
Definition: qwidget.h:984
bool isCheckable() const
Definition: qgroupbox.cpp:604
The QResizeEvent class contains event parameters for resize events.
Definition: qevent.h:349
The QGroupBox widget provides a group box frame with a title.
Definition: qgroupbox.h:57
Qt::MouseButton button() const
Returns the button that caused the event.
Definition: qevent.h:101
void setFlat(bool flat)
Definition: qgroupbox.cpp:545
QRect rect() const
void setEnabled(bool)
Definition: qwidget.cpp:3447
bool isEnabled() const
Definition: qwidget.h:948
The QMouseEvent class contains parameters that describe a mouse event.
Definition: qevent.h:85
The QChildEvent class contains event parameters for child object events.
Definition: qcoreevent.h:353
virtual QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *w=0) const =0
Returns the size of the element described by the specified option and type, based on the provided con...
int grabShortcut(const QKeySequence &key, Qt::ShortcutContext context=Qt::WindowShortcut)
Adds a shortcut to Qt&#39;s shortcut system that watches for the given key sequence in the given context...
Definition: qwidget.cpp:11747
QPalette palette
the palette that should be used when painting the control
Definition: qstyleoption.h:92
QStyle::SubControl pressedControl
Definition: qgroupbox.cpp:84
void setFocus()
Gives the keyboard input focus to this widget (or its focus proxy) if this widget or one of its paren...
Definition: qwidget.h:432
int shortcutId()
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qevent.h:683
bool isWidgetType() const
Returns true if the object is a widget; otherwise returns false.
Definition: qobject.h:146
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
bool checkable
whether the group box has a checkbox in its title
Definition: qgroupbox.h:64
#define Q_DECLARE_PUBLIC(Class)
Definition: qglobal.h:2477
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
void mouseMoveEvent(QMouseEvent *event)
Reimplemented Function
Definition: qgroupbox.cpp:743
void setTitle(const QString &title)
Definition: qgroupbox.cpp:239
FocusReason
Definition: qnamespace.h:1521
int midLineWidth
the mid-line width for drawing the panel
Definition: qstyleoption.h:845
bool isBrushSet(ColorGroup cg, ColorRole cr) const
Returns true if the ColorGroup cg and ColorRole cr has been set previously on this palette; otherwise...
Definition: qpalette.cpp:944
void resizeEvent(QResizeEvent *event)
Reimplemented Function
Definition: qgroupbox.cpp:323
int lineWidth
the line width for drawing the panel
Definition: qstyleoption.h:844
QSize minimumSizeHint() const
Reimplemented Function
Definition: qgroupbox.cpp:499
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI...
Definition: qstyle.h:68
The QStyleOptionGroupBox class describes the parameters for drawing a group box.
Definition: qstyleoption.h:834
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
bool isAutoRepeat() const
Returns true if this event comes from an auto-repeating key; returns false if it comes from an initia...
Definition: qevent.h:237
void mousePressEvent(QMouseEvent *event)
Reimplemented Function
Definition: qgroupbox.cpp:724
Qt::FocusReason reason()
Definition: qevent.cpp:1197
virtual SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, const QPoint &pt, const QWidget *widget=0) const =0
Returns the sub control at the given position in the given complex control (with the style options sp...
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
QObject * parent
Definition: qobject.h:92
QColor textColor
the color of the group box title
Definition: qstyleoption.h:843
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 updateGeometry()
Notifies the layout system that this widget has changed and may need to change geometry.
Definition: qwidget.cpp:10372
bool event(QEvent *)
This is the main event handler; it handles event event.
Definition: qwidget.cpp:8636
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
int height() const
Returns the height of the font.
The QPaintEvent class contains event parameters for paint events.
Definition: qevent.h:298
static void setLayoutItemMargins(int left, int top, int right, int bottom, QRect *rect, Qt::LayoutDirection dir)
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
~QGroupBox()
Destroys the group box.
Definition: qgroupbox.cpp:217
virtual void focusInEvent(QFocusEvent *)
This event handler can be reimplemented in a subclass to receive keyboard focus events (focus receive...
Definition: qwidget.cpp:9431
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
QStyle::SubControls subControls
This variable holds a bitwise OR of the sub-controls to be drawn for the complex control.
Definition: qstyleoption.h:693
The QFocusEvent class contains event parameters for widget focus events.
Definition: qevent.h:275
QObject * child() const
Returns the child object that was added or removed.
Definition: qcoreevent.h:358
void paintEvent(QPaintEvent *event)
Reimplemented Function
Definition: qgroupbox.cpp:331
void setFocusPolicy(Qt::FocusPolicy policy)
Definition: qwidget.cpp:7631