Qt 4.8
qtoolbarlayout.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 <qaction.h>
43 #include <qwidgetaction.h>
44 #include <qtoolbar.h>
45 #include <qstyleoption.h>
46 #include <qtoolbutton.h>
47 #include <qmenu.h>
48 #include <qdebug.h>
49 #include <qmath.h>
50 
51 #include "qmainwindowlayout_p.h"
52 #include "qtoolbarextension_p.h"
53 #include "qtoolbarlayout_p.h"
54 #include "qtoolbarseparator_p.h"
55 
56 #ifndef QT_NO_TOOLBAR
57 
59 
60 // qmainwindow.cpp
62 
63 /******************************************************************************
64 ** QToolBarItem
65 */
66 
68  : QWidgetItem(widget), action(0), customWidget(false)
69 {
70 }
71 
73 {
74  return action == 0 || !action->isVisible();
75 }
76 
77 /******************************************************************************
78 ** QToolBarLayout
79 */
80 
82  : QLayout(parent), expanded(false), animating(false), dirty(true),
83  expanding(false), empty(true), expandFlag(false), popupMenu(0)
84 {
86  if (!tb)
87  return;
88 
89  extension = new QToolBarExtension(tb);
91  extension->hide();
92  QObject::connect(tb, SIGNAL(orientationChanged(Qt::Orientation)),
93  extension, SLOT(setOrientation(Qt::Orientation)));
94 
95  setUsePopupMenu(qobject_cast<QMainWindow*>(tb->parentWidget()) == 0);
96 }
97 
99 {
100  while (!items.isEmpty()) {
101  QToolBarItem *item = items.takeFirst();
102  if (QWidgetAction *widgetAction = qobject_cast<QWidgetAction*>(item->action)) {
103  if (item->customWidget)
104  widgetAction->releaseWidget(item->widget());
105  }
106  delete item;
107  }
108 }
109 
111 {
113  if (!tb)
114  return;
115  QStyle *style = tb->style();
117  tb->initStyleOption(&opt);
119  + style->pixelMetric(QStyle::PM_ToolBarFrameWidth, &opt, tb));
121 }
122 
124 {
125  return expandFlag;
126 }
127 
129 {
130  if (!dirty && ((popupMenu == 0) == set))
131  invalidate();
132  if (!set) {
133  QObject::connect(extension, SIGNAL(clicked(bool)),
134  this, SLOT(setExpanded(bool)), Qt::UniqueConnection);
136  extension->setMenu(0);
137  delete popupMenu;
138  popupMenu = 0;
139  } else {
140  QObject::disconnect(extension, SIGNAL(clicked(bool)),
141  this, SLOT(setExpanded(bool)));
143  if (!popupMenu) {
144  popupMenu = new QMenu(extension);
145  }
147  }
148 }
149 
151 {
152  QToolBar *tb = static_cast<QToolBar *>(parent());
153  QMainWindow *mw = qobject_cast<QMainWindow *>(tb->parent());
154  Qt::Orientation o = tb->orientation();
155  setUsePopupMenu(!mw || tb->isFloating() || perp(o, expandedSize(mw->size())) >= perp(o, mw->size()));
156 }
157 
159 {
160  qWarning() << "QToolBarLayout::addItem(): please use addAction() instead";
161  return;
162 }
163 
165 {
166  if (index < 0 || index >= items.count())
167  return 0;
168  return items.at(index);
169 }
170 
172 {
173  if (index < 0 || index >= items.count())
174  return 0;
175  QToolBarItem *item = items.takeAt(index);
176 
177  if (popupMenu)
178  popupMenu->removeAction(item->action);
179 
180  QWidgetAction *widgetAction = qobject_cast<QWidgetAction*>(item->action);
181  if (widgetAction != 0 && item->customWidget) {
182  widgetAction->releaseWidget(item->widget());
183  } else {
184  // destroy the QToolButton/QToolBarSeparator
185  item->widget()->hide();
186  item->widget()->deleteLater();
187  }
188 
189  invalidate();
190  return item;
191 }
192 
194 {
195  index = qMax(0, index);
196  index = qMin(items.count(), index);
197 
198  QToolBarItem *item = createItem(action);
199  if (item) {
200  items.insert(index, item);
201  invalidate();
202  }
203 }
204 
206 {
207  for (int i = 0; i < items.count(); ++i) {
208  if (items.at(i)->action == action)
209  return i;
210  }
211  return -1;
212 }
213 
215 {
216  return items.count();
217 }
218 
220 {
221  if (dirty)
222  updateGeomArray();
223  return empty;
224 }
225 
227 {
228  dirty = true;
230 }
231 
232 Qt::Orientations QToolBarLayout::expandingDirections() const
233 {
234  if (dirty)
235  updateGeomArray();
237  if (!tb)
238  return Qt::Orientations(0);
239  Qt::Orientation o = tb->orientation();
240  return expanding ? Qt::Orientations(o) : Qt::Orientations(0);
241 }
242 
244 {
246  if (!tb)
247  return false;
249  return tb->isMovable() && win != 0;
250 }
251 
253 {
254  if (!dirty)
255  return;
256 
257  QToolBarLayout *that = const_cast<QToolBarLayout*>(this);
258 
260  if (!tb)
261  return;
262  QStyle *style = tb->style();
264  tb->initStyleOption(&opt);
265  const int handleExtent = movable()
266  ? style->pixelMetric(QStyle::PM_ToolBarHandleExtent, &opt, tb) : 0;
267  const int margin = this->margin();
268  const int spacing = this->spacing();
269  const int extensionExtent = style->pixelMetric(QStyle::PM_ToolBarExtensionExtent, &opt, tb);
270  Qt::Orientation o = tb->orientation();
271 
272  that->minSize = QSize(0, 0);
273  that->hint = QSize(0, 0);
274  rperp(o, that->minSize) = style->pixelMetric(QStyle::PM_ToolBarHandleExtent, &opt, tb);
275  rperp(o, that->hint) = style->pixelMetric(QStyle::PM_ToolBarHandleExtent, &opt, tb);
276 
277  that->expanding = false;
278  that->empty = false;
279 
280  QVector<QLayoutStruct> a(items.count() + 1); // + 1 for the stretch
281 
282  int count = 0;
283  for (int i = 0; i < items.count(); ++i) {
284  QToolBarItem *item = items.at(i);
285 
286  QSize max = item->maximumSize();
287  QSize min = item->minimumSize();
288  QSize hint = item->sizeHint();
289  Qt::Orientations exp = item->expandingDirections();
290  bool empty = item->isEmpty();
291 
292  that->expanding = expanding || exp & o;
293 
294 
295  if (item->widget()) {
297  that->expandFlag = true;
298  }
299  }
300 
301  if (!empty) {
302  if (count == 0) // the minimum size only displays one widget
303  rpick(o, that->minSize) += pick(o, min);
304  int s = perp(o, minSize);
305  rperp(o, that->minSize) = qMax(s, perp(o, min));
306 
307  //we only add spacing before item (ie never before the first one)
308  rpick(o, that->hint) += (count == 0 ? 0 : spacing) + pick(o, hint);
309  s = perp(o, that->hint);
310  rperp(o, that->hint) = qMax(s, perp(o, hint));
311  ++count;
312  }
313 
314  a[i].sizeHint = pick(o, hint);
315  a[i].maximumSize = pick(o, max);
316  a[i].minimumSize = pick(o, min);
317  a[i].expansive = exp & o;
318  if (o == Qt::Horizontal)
319  a[i].stretch = item->widget()->sizePolicy().horizontalStretch();
320  else
321  a[i].stretch = item->widget()->sizePolicy().verticalStretch();
322  a[i].empty = empty;
323  }
324 
325  that->geomArray = a;
326  that->empty = count == 0;
327 
328  rpick(o, that->minSize) += handleExtent;
329  that->minSize += QSize(2*margin, 2*margin);
330  if (items.count() > 1)
331  rpick(o, that->minSize) += spacing + extensionExtent;
332 
333  rpick(o, that->hint) += handleExtent;
334  that->hint += QSize(2*margin, 2*margin);
335  that->dirty = false;
336 #ifdef Q_WS_MAC
337  if (QMainWindow *mw = qobject_cast<QMainWindow *>(parentWidget()->parentWidget())) {
338  if (mw->unifiedTitleAndToolBarOnMac()
339  && mw->toolBarArea(static_cast<QToolBar *>(parentWidget())) == Qt::TopToolBarArea) {
340  if (expandFlag) {
341  tb->setMaximumSize(0xFFFFFF, 0xFFFFFF);
342  } else {
343  tb->setMaximumSize(hint);
344  }
345  }
346  }
347 #endif
348 
349  that->dirty = false;
350 }
351 
353 {
355  return a != 0 && a->defaultWidget() == item->widget();
356 }
357 
359 {
361  if (!tb)
362  return;
363  QStyle *style = tb->style();
365  tb->initStyleOption(&opt);
366  const int margin = this->margin();
367  const int extensionExtent = style->pixelMetric(QStyle::PM_ToolBarExtensionExtent, &opt, tb);
368  Qt::Orientation o = tb->orientation();
369 
370  QLayout::setGeometry(rect);
371 
372  bool ranOutOfSpace = false;
373  if (!animating)
374  ranOutOfSpace = layoutActions(rect.size());
375 
376  if (expanded || animating || ranOutOfSpace) {
378  if (QMainWindow *win = qobject_cast<QMainWindow*>(tb->parentWidget()))
379  area = win->toolBarArea(tb);
380  QSize hint = sizeHint();
381 
382  QPoint pos;
383  rpick(o, pos) = pick(o, rect.bottomRight()) - margin - extensionExtent + 2;
384  if (area == Qt::LeftToolBarArea || area == Qt::TopToolBarArea)
385  rperp(o, pos) = perp(o, rect.topLeft()) + margin;
386  else
387  rperp(o, pos) = perp(o, rect.bottomRight()) - margin - (perp(o, hint) - 2*margin) + 1;
388  QSize size;
389  rpick(o, size) = extensionExtent;
390  rperp(o, size) = perp(o, hint) - 2*margin;
391  QRect r(pos, size);
392 
393  if (o == Qt::Horizontal)
394  r = QStyle::visualRect(parentWidget()->layoutDirection(), rect, r);
395 
397 
398  if (extension->isHidden())
399  extension->show();
400  } else {
401  if (!extension->isHidden())
402  extension->hide();
403  }
404 #ifdef Q_WS_MAC
405  // Nothing to do for Carbon... probably
406 # ifdef QT_MAC_USE_COCOA
407  if (QMainWindow *win = qobject_cast<QMainWindow*>(tb->parentWidget())) {
408  Qt::ToolBarArea area = win->toolBarArea(tb);
409  if (win->unifiedTitleAndToolBarOnMac() && area == Qt::TopToolBarArea) {
411  }
412  }
413 # endif
414 #endif
415 
416 }
417 
419 {
420  if (dirty)
421  updateGeomArray();
422 
423  QRect rect(0, 0, size.width(), size.height());
424 
425  QList<QWidget*> showWidgets, hideWidgets;
426 
428  if (!tb)
429  return false;
430  QStyle *style = tb->style();
432  tb->initStyleOption(&opt);
433  const int handleExtent = movable()
434  ? style->pixelMetric(QStyle::PM_ToolBarHandleExtent, &opt, tb) : 0;
435  const int margin = this->margin();
436  const int spacing = this->spacing();
437  const int extensionExtent = style->pixelMetric(QStyle::PM_ToolBarExtensionExtent, &opt, tb);
438  Qt::Orientation o = tb->orientation();
439  bool extensionMenuContainsOnlyWidgetActions = true;
440 
441  int space = pick(o, rect.size()) - 2*margin - handleExtent;
442  if (space <= 0)
443  return false; // nothing to do.
444 
445  if(popupMenu)
446  popupMenu->clear();
447 
448  bool ranOutOfSpace = false;
449  int rows = 0;
450  int rowPos = perp(o, rect.topLeft()) + margin;
451  int i = 0;
452  while (i < items.count()) {
454 
455  int start = i;
456  int size = 0;
457  int prev = -1;
458  int rowHeight = 0;
459  int count = 0;
460  int maximumSize = 0;
461  bool expansiveRow = false;
462  for (; i < items.count(); ++i) {
463  if (a[i].empty)
464  continue;
465 
466  int newSize = size + (count == 0 ? 0 : spacing) + a[i].minimumSize;
467  if (prev != -1 && newSize > space) {
468  if (rows == 0)
469  ranOutOfSpace = true;
470  // do we have to move the previous item to the next line to make space for
471  // the extension button?
472  if (count > 1 && size + spacing + extensionExtent > space)
473  i = prev;
474  break;
475  }
476 
477  if (expanded)
478  rowHeight = qMax(rowHeight, perp(o, items.at(i)->sizeHint()));
479  expansiveRow = expansiveRow || a[i].expansive;
480  size = newSize;
481  maximumSize += spacing + (a[i].expansive ? a[i].maximumSize : a[i].smartSizeHint());
482  prev = i;
483  ++count;
484  }
485 
486  // stretch at the end
487  a[i].sizeHint = 0;
488  a[i].maximumSize = QWIDGETSIZE_MAX;
489  a[i].minimumSize = 0;
490  a[i].expansive = true;
491  a[i].stretch = 0;
492  a[i].empty = true;
493 
494  if (expansiveRow && maximumSize < space) {
495  expansiveRow = false;
496  a[i].maximumSize = space - maximumSize;
497  }
498 
499  qGeomCalc(a, start, i - start + (expansiveRow ? 0 : 1), 0,
500  space - (ranOutOfSpace ? (extensionExtent + spacing) : 0),
501  spacing);
502 
503  for (int j = start; j < i; ++j) {
504  QToolBarItem *item = items.at(j);
505 
506  if (a[j].empty) {
507  if (!item->widget()->isHidden())
508  hideWidgets << item->widget();
509  continue;
510  }
511 
512  QPoint pos;
513  rpick(o, pos) = margin + handleExtent + a[j].pos;
514  rperp(o, pos) = rowPos;
515  QSize size;
516  rpick(o, size) = a[j].size;
517  if (expanded)
518  rperp(o, size) = rowHeight;
519  else
520  rperp(o, size) = perp(o, rect.size()) - 2*margin;
521  QRect r(pos, size);
522 
523  if (o == Qt::Horizontal)
524  r = QStyle::visualRect(parentWidget()->layoutDirection(), rect, r);
525 
526  item->setGeometry(r);
527 
528  if (item->widget()->isHidden())
529  showWidgets << item->widget();
530  }
531 
532  if (!expanded) {
533  for (int j = i; j < items.count(); ++j) {
534  QToolBarItem *item = items.at(j);
535  if (!item->widget()->isHidden())
536  hideWidgets << item->widget();
537  if (popupMenu) {
538  if (!defaultWidgetAction(item)) {
539  popupMenu->addAction(item->action);
540  extensionMenuContainsOnlyWidgetActions = false;
541  }
542  }
543  }
544  break;
545  }
546 
547  rowPos += rowHeight + spacing;
548  ++rows;
549  }
550 
551  // if we are using a popup menu, not the expadning toolbar effect, we cannot move custom
552  // widgets into the menu. If only custom widget actions are chopped off, the popup menu
553  // is empty. So we show the little extension button to show something is chopped off,
554  // but we make it disabled.
555  extension->setEnabled(popupMenu == 0 || !extensionMenuContainsOnlyWidgetActions);
556 
557  // we have to do the show/hide here, because it triggers more calls to setGeometry :(
558  for (int i = 0; i < showWidgets.count(); ++i)
559  showWidgets.at(i)->show();
560  for (int i = 0; i < hideWidgets.count(); ++i)
561  hideWidgets.at(i)->hide();
562 
563  return ranOutOfSpace;
564 }
565 
567 {
568  if (dirty)
569  updateGeomArray();
570 
572  if (!tb)
573  return QSize(0, 0);
575  Qt::Orientation o = tb->orientation();
576  QStyle *style = tb->style();
578  tb->initStyleOption(&opt);
579  const int handleExtent = movable()
580  ? style->pixelMetric(QStyle::PM_ToolBarHandleExtent, &opt, tb) : 0;
581  const int margin = this->margin();
582  const int spacing = this->spacing();
583  const int extensionExtent = style->pixelMetric(QStyle::PM_ToolBarExtensionExtent, &opt, tb);
584 
585  int total_w = 0;
586  int count = 0;
587  for (int x = 0; x < items.count(); ++x) {
588  if (!geomArray[x].empty) {
589  total_w += (count == 0 ? 0 : spacing) + geomArray[x].minimumSize;
590  ++count;
591  }
592  }
593  if (count == 0)
594  return QSize(0, 0);
595 
596  int min_w = pick(o, size);
597  int rows = (int)qSqrt(qreal(count));
598  if (rows == 1)
599  ++rows; // we want to expand to at least two rows
600  int space = total_w/rows + spacing + extensionExtent;
601  space = qMax(space, min_w - 2*margin - handleExtent);
602  if (win != 0)
603  space = qMin(space, pick(o, win->size()) - 2*margin - handleExtent);
604 
605  int w = 0;
606  int h = 0;
607  int i = 0;
608  while (i < items.count()) {
609  int count = 0;
610  int size = 0;
611  int prev = -1;
612  int rowHeight = 0;
613  for (; i < items.count(); ++i) {
614  if (geomArray[i].empty)
615  continue;
616 
617  int newSize = size + (count == 0 ? 0 : spacing) + geomArray[i].minimumSize;
618  rowHeight = qMax(rowHeight, perp(o, items.at(i)->sizeHint()));
619  if (prev != -1 && newSize > space) {
620  if (count > 1 && size + spacing + extensionExtent > space) {
621  size -= spacing + geomArray[prev].minimumSize;
622  i = prev;
623  }
624  break;
625  }
626 
627  size = newSize;
628  prev = i;
629  ++count;
630  }
631 
632  w = qMax(size, w);
633  h += rowHeight + spacing;
634  }
635 
636  w += 2*margin + handleExtent + spacing + extensionExtent;
637  w = qMax(w, min_w);
638  if (win != 0)
639  w = qMin(w, pick(o, win->size()));
640  h += 2*margin - spacing; //there is no spacing before the first row
641 
642  QSize result;
643  rpick(o, result) = w;
644  rperp(o, result) = h;
645  return result;
646 }
647 
649 {
651  if (!tb)
652  return;
653  if (exp == expanded && !tb->isWindow())
654  return;
655 
656  expanded = exp;
658 
659  if (QMainWindow *win = qobject_cast<QMainWindow*>(tb->parentWidget())) {
660 #ifdef QT_NO_DOCKWIDGET
661  animating = false;
662 #else
663  animating = !tb->isWindow() && win->isAnimated();
664 #endif
666  if (expanded) {
667  tb->raise();
668  } else {
669  QList<int> path = layout->layoutState.indexOf(tb);
670  if (!path.isEmpty()) {
671  QRect rect = layout->layoutState.itemRect(path);
672  layoutActions(rect.size());
673  }
674  }
676  }
677 }
678 
680 {
681  if (dirty)
682  updateGeomArray();
683  return minSize;
684 }
685 
687 {
688  if (dirty)
689  updateGeomArray();
690  return hint;
691 }
692 
694 {
695  bool customWidget = false;
696  bool standardButtonWidget = false;
697  QWidget *widget = 0;
699  if (!tb)
700  return (QToolBarItem *)0;
701 
702  if (QWidgetAction *widgetAction = qobject_cast<QWidgetAction *>(action)) {
703  widget = widgetAction->requestWidget(tb);
704  if (widget != 0) {
706  customWidget = true;
707  }
708  } else if (action->isSeparator()) {
709  QToolBarSeparator *sep = new QToolBarSeparator(tb);
710  connect(tb, SIGNAL(orientationChanged(Qt::Orientation)),
711  sep, SLOT(setOrientation(Qt::Orientation)));
712  widget = sep;
713  }
714 
715  if (!widget) {
716  QToolButton *button = new QToolButton(tb);
717  button->setAutoRaise(true);
718  button->setFocusPolicy(Qt::NoFocus);
719  button->setIconSize(tb->iconSize());
720  button->setToolButtonStyle(tb->toolButtonStyle());
721  QObject::connect(tb, SIGNAL(iconSizeChanged(QSize)),
722  button, SLOT(setIconSize(QSize)));
723  QObject::connect(tb, SIGNAL(toolButtonStyleChanged(Qt::ToolButtonStyle)),
724  button, SLOT(setToolButtonStyle(Qt::ToolButtonStyle)));
725  button->setDefaultAction(action);
726  QObject::connect(button, SIGNAL(triggered(QAction*)), tb, SIGNAL(actionTriggered(QAction*)));
727  widget = button;
728  standardButtonWidget = true;
729  }
730 
731  widget->hide();
732  QToolBarItem *result = new QToolBarItem(widget);
733  if (standardButtonWidget)
735  result->customWidget = customWidget;
736  result->action = action;
737  return result;
738 }
739 
741 
742 #endif // QT_NO_TOOLBAR
bool isSeparator() const
Returns true if this action is a separator action; otherwise it returns false.
Definition: qaction.cpp:839
QSize maximumSize() const
Reimplemented Function
bool isMovable() const
Definition: qtoolbar.cpp:656
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
double qreal
Definition: qglobal.h:1193
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
void setSpacing(int)
Definition: qlayout.cpp:469
QSize size() const
QPointer< QWidget > widget
void updateGeomArray() const
QSize sizeHint() const
Reimplemented Function
void setGeometry(const QRect &r)
Reimplemented Function
bool isEmpty() const
Reimplemented Function
QRect itemRect(const QList< int > &path) const
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
int count() const
Must be implemented in subclasses to return the number of items in the layout.
void setDefaultAction(QAction *)
Sets the default action to action.
QSize minimumSize() const
Returns the minimum size of this layout.
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
Policy horizontalPolicy() const
Definition: qsizepolicy.h:118
#define SLOT(a)
Definition: qobjectdefs.h:226
static int & rpick(Qt::Orientation o, QPoint &pos)
#define QWIDGETSIZE_MAX
Defines the maximum size for a QWidget object.
Definition: qwidget.h:1087
bool movable() const
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void setMaximumSize(const QSize &)
Definition: qwidget.h:972
The QStyleOptionToolBar class is used to describe the parameters for drawing a toolbar.
Definition: qstyleoption.h:369
QLayoutItem * takeAt(int index)
Must be implemented in subclasses to remove the layout item at index from the layout, and return the item.
void insert(int i, const T &t)
Inserts value at index position i in the list.
Definition: qlist.h:575
QMainWindowLayoutState layoutState
virtual void setGeometry(const QRect &)
Reimplemented Function
Definition: qlayout.cpp:655
long ASN1_INTEGER_get ASN1_INTEGER * a
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
QAction * action
QSize expandedSize(const QSize &size) const
void setGeometry(int x, int y, int w, int h)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qwidget.h:1017
void invalidate()
Reimplemented Function
Definition: qlayout.cpp:673
T * qobject_cast(QObject *object)
Definition: qobject.h:375
QAction * addAction(const QString &text)
This convenience function creates a new action with text.
Definition: qmenu.cpp:1453
bool empty() const
This function is provided for STL compatibility.
Definition: qvector.h:285
int spacing() const
QVector< QLayoutStruct > geomArray
int horizontalStretch() const
Definition: qsizepolicy.h:144
virtual QWidget * widget()
Returns the widget managed by this item.
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
QToolBarItem * createItem(QAction *action)
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
QStyle * style() const
Definition: qwidget.cpp:2742
QSize maximumSize() const
Returns the maximum size of this layout.
Definition: qlayout.cpp:1181
bool isVisible() const
Definition: qaction.cpp:1246
void insertAction(int index, QAction *action)
bool isHidden() const
Returns true if the widget is hidden, otherwise returns false.
Definition: qwidget.h:1008
QWidget * parentWidget() const
Returns the parent widget of this layout, or 0 if this layout is not installed on any widget...
Definition: qlayout.cpp:616
#define SIGNAL(a)
Definition: qobjectdefs.h:227
NSWindow * window
int width() const
Returns the width.
Definition: qsize.h:126
void setExpanded(bool b)
void setAlignment(Qt::Alignment a)
Sets the alignment of this item to alignment.
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
The QLayoutItem class provides an abstract item that a QLayout manipulates.
Definition: qlayoutitem.h:64
QLayoutItem * itemAt(int index) const
Must be implemented in subclasses to return the layout item at index.
Qt::Orientations expandingDirections() const
Reimplemented Function
QPoint bottomRight() const
Returns the position of the rectangle&#39;s bottom-right corner.
Definition: qrect.h:291
bool isEmpty() const
Returns true if the widget is hidden; otherwise returns false.
T takeFirst()
Removes the first item in the list and returns it.
Definition: qlist.h:489
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 raise()
Raises this widget to the top of the parent widget&#39;s stack.
Definition: qwidget.cpp:11901
The QToolBar class provides a movable panel that contains a set of controls.
Definition: qtoolbar.h:62
The QLayout class is the base class of geometry managers.
Definition: qlayout.h:90
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
Q_CORE_EXPORT void qWarning(const char *,...)
int verticalStretch() const
Definition: qsizepolicy.h:145
QList< QToolBarItem * > items
bool layoutActions(const QSize &size)
QToolBarExtension * extension
void show()
Shows the widget and its child widgets.
The QWidgetItem class is a layout item that represents a widget.
Definition: qlayoutitem.h:122
void setEnabled(bool)
Definition: qwidget.cpp:3447
void clear()
Removes all the menu&#39;s actions.
Definition: qmenu.cpp:1755
void hide()
Hides the widget.
Definition: qwidget.h:501
ToolBarArea
Definition: qnamespace.h:1353
QMainWindowLayout * qt_mainwindow_layout(const QMainWindow *window)
static int perp(bool vertical, const QSize &size)
void qGeomCalc(QVector< QLayoutStruct > &chain, int start, int count, int pos, int space, int spacer)
QSize minimumSize() const
Reimplemented Function
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
The QWidgetAction class extends QAction by an interface for inserting custom widgets into action base...
Definition: qwidgetaction.h:57
QToolBarItem(QWidget *widget)
static QRect visualRect(Qt::LayoutDirection direction, const QRect &boundingRect, const QRect &logicalRect)
Returns the given logicalRectangle converted to screen coordinates based on the specified direction...
Definition: qstyle.cpp:2087
QToolBarLayout(QWidget *parent=0)
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus...
Definition: qmenu.h:72
bool isFloating() const
Definition: qtoolbar.cpp:694
Qt::Orientation orientation() const
orientation of the toolbar
Definition: qtoolbar.cpp:769
void setIconSize(const QSize &size)
void setMenu(QMenu *menu)
Associates the given menu with this tool button.
void setGeometry(const QRect &)
Reimplemented Function
void invalidate()
Reimplemented Function
QSizePolicy sizePolicy
the default layout behavior of the widget
Definition: qwidget.h:171
void setUsePopupMenu(bool set)
QSize iconSize() const
size of icons in the toolbar.
Definition: qtoolbar.cpp:785
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
void removeAction(QAction *action)
Removes the action action from this widget&#39;s list of actions.
Definition: qwidget.cpp:3386
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QMainWindow class provides a main application window.
Definition: qmainwindow.h:63
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI...
Definition: qstyle.h:68
void setAutoRaise(bool enable)
QList< int > indexOf(QWidget *widget) const
static bool defaultWidgetAction(QToolBarItem *item)
void initStyleOption(QStyleOptionToolBar *option) const
Definition: qtoolbar.cpp:1374
int height() const
Returns the height.
Definition: qsize.h:129
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
void addItem(QLayoutItem *item)
Implemented in subclasses to add an item.
int indexOf(QAction *action) const
T takeAt(int i)
Removes the item at index position i and returns it.
Definition: qlist.h:484
QWidget * defaultWidget() const
Returns the default widget.
void setPopupMode(ToolButtonPopupMode mode)
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
quint16 index
static int pick(bool vertical, const QSize &size)
virtual QWidget * widget()
If this item is a QWidget, it is returned as a QWidget; otherwise 0 is returned.
bool hasExpandFlag() const
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
ToolButtonStyle
Definition: qnamespace.h:1572
Qt::ToolButtonStyle toolButtonStyle
the style of toolbar buttons
Definition: qtoolbar.h:70
static int & rperp(Qt::Orientation o, QPoint &pos)
int margin() const
The QToolButton class provides a quick-access button to commands or options, usually used inside a QT...
Definition: qtoolbutton.h:59
QLayout * layout()
Reimplemented Function
void apply(bool animate)
void releaseWidget(QWidget *widget)
Releases the specified widget.
void fixSizeInUnifiedToolbar(QToolBar *tb) const
void setMargin(int)
Definition: qlayout.cpp:464
Orientation
Definition: qnamespace.h:174
QToolBarAreaLayout toolBarAreaLayout
qreal qSqrt(qreal v)
Definition: qmath.h:205
Qt::Orientations expandingDirections() const
Returns whether this layout can make use of more space than sizeHint().
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
void deleteLater()
Schedules this object for deletion.
Definition: qobject.cpp:2145
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64
void setToolButtonStyle(Qt::ToolButtonStyle style)
void updateMarginAndSpacing()
void setFocusPolicy(Qt::FocusPolicy policy)
Definition: qwidget.cpp:7631
static int area(const QSize &s)
Definition: qicon.cpp:155
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288
QSize sizeHint() const
Implemented in subclasses to return the preferred size of this item.