Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qtoolbarlayout.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include <qapplication.h>
5#include <qaction.h>
6#include <qwidgetaction.h>
7#include <qtoolbar.h>
8#include <qstyleoption.h>
9#if QT_CONFIG(toolbutton)
10#include <qtoolbutton.h>
11#endif
12#include <qmenu.h>
13#include <qdebug.h>
14#include <qmath.h>
15#ifdef Q_OS_MACOS
16#include <qpa/qplatformnativeinterface.h>
17#endif
18
19#include "qmainwindowlayout_p.h"
20#if QT_CONFIG(toolbutton)
21#include "qtoolbarextension_p.h"
22#endif
23#include "qtoolbarlayout_p.h"
24#include "qtoolbarseparator_p.h"
25
27
28// qmainwindow.cpp
30
31/******************************************************************************
32** QToolBarItem
33*/
34
39
41{
42 return action == nullptr || !action->isVisible();
43}
44
45/******************************************************************************
46** QToolBarLayout
47*/
48
50 : QLayout(parent), expanded(false), animating(false), dirty(true),
51 expanding(false), empty(true), expandFlag(false), popupMenu(nullptr)
52{
53 QToolBar *tb = qobject_cast<QToolBar*>(parent);
54 if (!tb)
55 return;
56
57 extension = new QToolBarExtension(tb);
58 extension->setFocusPolicy(Qt::NoFocus);
59 extension->hide();
60 QObject::connect(tb, SIGNAL(orientationChanged(Qt::Orientation)),
61 extension, SLOT(setOrientation(Qt::Orientation)));
62
63 setUsePopupMenu(qobject_cast<QMainWindow*>(tb->parentWidget()) == 0);
64}
65
67{
68 while (!items.isEmpty()) {
69 QToolBarItem *item = items.takeFirst();
70 if (QWidgetAction *widgetAction = qobject_cast<QWidgetAction*>(item->action)) {
71 if (item->customWidget)
72 widgetAction->releaseWidget(item->widget());
73 }
74 delete item;
75 }
76}
77
79{
80 QToolBar *tb = qobject_cast<QToolBar*>(parentWidget());
81 if (!tb)
82 return;
83 QStyle *style = tb->style();
84 QStyleOptionToolBar opt;
85 tb->initStyleOption(&opt);
86 const int margin = style->pixelMetric(QStyle::PM_ToolBarItemMargin, &opt, tb)
88 setContentsMargins(margin, margin, margin, margin);
90}
91
93{
94 return expandFlag;
95}
96
98{
99 if (!dirty && ((popupMenu == nullptr) == set))
100 invalidate();
101 if (!set) {
102 QObject::connect(extension, SIGNAL(clicked(bool)),
104 extension->setPopupMode(QToolButton::DelayedPopup);
105 extension->setMenu(nullptr);
106 delete popupMenu;
107 popupMenu = nullptr;
108 } else {
109 QObject::disconnect(extension, SIGNAL(clicked(bool)),
110 this, SLOT(setExpanded(bool)));
111 extension->setPopupMode(QToolButton::InstantPopup);
112 if (!popupMenu) {
113 popupMenu = new QMenu(extension);
114 }
115 extension->setMenu(popupMenu);
116 }
117}
118
120{
121 QToolBar *tb = static_cast<QToolBar *>(parent());
122 QMainWindow *mw = qobject_cast<QMainWindow *>(tb->parent());
123 Qt::Orientation o = tb->orientation();
124 setUsePopupMenu(!mw || tb->isFloating() || perp(o, expandedSize(mw->size())) >= perp(o, mw->size()));
125}
126
128{
129 qWarning("QToolBarLayout::addItem(): please use addAction() instead");
130 return;
131}
132
134{
135 if (index < 0 || index >= items.size())
136 return nullptr;
137 return items.at(index);
138}
139
141{
142 if (index < 0 || index >= items.size())
143 return nullptr;
144 QToolBarItem *item = items.takeAt(index);
145
146 if (popupMenu)
147 popupMenu->removeAction(item->action);
148
149 QWidgetAction *widgetAction = qobject_cast<QWidgetAction*>(item->action);
150 if (widgetAction != nullptr && item->customWidget) {
151 widgetAction->releaseWidget(item->widget());
152 } else {
153 // destroy the QToolButton/QToolBarSeparator
154 item->widget()->hide();
155 item->widget()->deleteLater();
156 }
157
158 invalidate();
159 return item;
160}
161
163{
164 index = qMax(0, index);
165 index = qMin(items.size(), index);
166
167 QToolBarItem *item = createItem(action);
168 if (item) {
169 items.insert(index, item);
170 invalidate();
171 }
172}
173
174int QToolBarLayout::indexOf(const QAction *action) const
175{
176 for (int i = 0; i < items.size(); ++i) {
177 if (items.at(i)->action == action)
178 return i;
179 }
180 return -1;
181}
182
184{
185 return items.size();
186}
187
189{
190 if (dirty)
191 updateGeomArray();
192 return empty;
193}
194
196{
197 dirty = true;
199}
200
202{
203 if (dirty)
204 updateGeomArray();
205 QToolBar *tb = qobject_cast<QToolBar*>(parentWidget());
206 if (!tb)
207 return {};
208 Qt::Orientation o = tb->orientation();
209 return expanding ? Qt::Orientations(o) : Qt::Orientations{};
210}
211
213{
214 QToolBar *tb = qobject_cast<QToolBar*>(parentWidget());
215 if (!tb)
216 return false;
217 QMainWindow *win = qobject_cast<QMainWindow*>(tb->parentWidget());
218 return tb->isMovable() && win != nullptr;
219}
220
221void QToolBarLayout::updateGeomArray() const
222{
223 if (!dirty)
224 return;
225
226 QToolBarLayout *that = const_cast<QToolBarLayout*>(this);
227
228 QToolBar *tb = qobject_cast<QToolBar*>(parentWidget());
229 if (!tb)
230 return;
231 QStyle *style = tb->style();
232 QStyleOptionToolBar opt;
233 tb->initStyleOption(&opt);
234 const int handleExtent = movable()
236 const QMargins margins = contentsMargins();
237 const int spacing = this->spacing();
238 const int extensionExtent = style->pixelMetric(QStyle::PM_ToolBarExtensionExtent, &opt, tb);
239 Qt::Orientation o = tb->orientation();
240
241 that->minSize = QSize(0, 0);
242 that->hint = QSize(0, 0);
243 rperp(o, that->minSize) = style->pixelMetric(QStyle::PM_ToolBarHandleExtent, &opt, tb);
244 rperp(o, that->hint) = style->pixelMetric(QStyle::PM_ToolBarHandleExtent, &opt, tb);
245
246 that->expanding = false;
247 that->empty = false;
248
249 QList<QLayoutStruct> a(items.size() + 1); // + 1 for the stretch
250
251 int count = 0;
252 for (int i = 0; i < items.size(); ++i) {
253 QToolBarItem *item = items.at(i);
254
255 QSize max = item->maximumSize();
256 QSize min = item->minimumSize();
257 QSize hint = item->sizeHint();
258 Qt::Orientations exp = item->expandingDirections();
259 bool empty = item->isEmpty();
260
261 that->expanding = expanding || exp & o;
262
263
264 if (item->widget()) {
265 if ((item->widget()->sizePolicy().horizontalPolicy() & QSizePolicy::ExpandFlag)) {
266 that->expandFlag = true;
267 }
268 }
269
270 if (!empty) {
271 if (count == 0) // the minimum size only displays one widget
272 rpick(o, that->minSize) += pick(o, min);
273 int s = perp(o, minSize);
274 rperp(o, that->minSize) = qMax(s, perp(o, min));
275
276 //we only add spacing before item (ie never before the first one)
277 rpick(o, that->hint) += (count == 0 ? 0 : spacing) + pick(o, hint);
278 s = perp(o, that->hint);
279 rperp(o, that->hint) = qMax(s, perp(o, hint));
280 ++count;
281 }
282
283 a[i].sizeHint = pick(o, hint);
284 a[i].maximumSize = pick(o, max);
285 a[i].minimumSize = pick(o, min);
286 a[i].expansive = exp & o;
287 if (o == Qt::Horizontal)
288 a[i].stretch = item->widget()->sizePolicy().horizontalStretch();
289 else
290 a[i].stretch = item->widget()->sizePolicy().verticalStretch();
291 a[i].empty = empty;
292 }
293
294 that->geomArray = a;
295 that->empty = count == 0;
296
297 rpick(o, that->minSize) += handleExtent;
298 that->minSize += QSize(pick(Qt::Horizontal, margins), pick(Qt::Vertical, margins));
299 if (items.size() > 1)
300 rpick(o, that->minSize) += spacing + extensionExtent;
301
302 rpick(o, that->hint) += handleExtent;
303 that->hint += QSize(pick(Qt::Horizontal, margins), pick(Qt::Vertical, margins));
304 that->dirty = false;
305}
306
308{
309 QWidgetAction *a = qobject_cast<QWidgetAction*>(item->action);
310 return a != nullptr && a->defaultWidget() == item->widget();
311}
312
314{
315#ifdef Q_OS_MACOS
316 QToolBar *tb = qobject_cast<QToolBar*>(parentWidget());
317 if (!tb)
318 return;
319
320 QRect rect = geometry();
321
322 QMainWindow *mainWindow = qobject_cast<QMainWindow*>(tb->parentWidget());
323 if (!mainWindow || !mainWindow->isWindow() || !mainWindow->unifiedTitleAndToolBarOnMac())
324 return;
325
327 if (!nativeInterface)
328 return; // Not Cocoa platform plugin.
330 nativeInterface->nativeResourceFunctionForIntegration("registerContentBorderArea");
331 if (!function)
332 return; // Not Cocoa platform plugin.
333
334 QPoint upper = tb->mapToParent(rect.topLeft());
335 QPoint lower = tb->mapToParent(rect.bottomLeft() + QPoint(0, 1));
336
337 typedef void (*RegisterContentBorderAreaFunction)(QWindow *window, void *identifier, int upper, int lower);
338 if (mainWindow->toolBarArea(tb) == Qt::TopToolBarArea) {
339 (reinterpret_cast<RegisterContentBorderAreaFunction>(function))(tb->window()->windowHandle(), tb, upper.y(), lower.y());
340 } else {
341 (reinterpret_cast<RegisterContentBorderAreaFunction>(function))(tb->window()->windowHandle(), tb, 0, 0);
342 }
343#endif
344}
345
347{
348 QToolBar *tb = qobject_cast<QToolBar*>(parentWidget());
349 if (!tb)
350 return;
351 QStyle *style = tb->style();
352 QStyleOptionToolBar opt;
353 tb->initStyleOption(&opt);
354 const QMargins margins = contentsMargins();
355 const int extensionExtent = style->pixelMetric(QStyle::PM_ToolBarExtensionExtent, &opt, tb);
356 Qt::Orientation o = tb->orientation();
357
359
361
362 bool ranOutOfSpace = false;
363 if (!animating)
364 ranOutOfSpace = layoutActions(rect.size());
365
366 if (expanded || animating || ranOutOfSpace) {
368 if (QMainWindow *win = qobject_cast<QMainWindow*>(tb->parentWidget()))
369 area = win->toolBarArea(tb);
370 QSize hint = sizeHint();
371
372 QPoint pos;
373 rpick(o, pos) = pick(o, rect.bottomRight()) -
374 pick(o, QSize(margins.bottom(), margins.right())) - extensionExtent + 2;
376 rperp(o, pos) = perp(o, rect.topLeft()) +
377 perp(o, QSize(margins.top(), margins.left()));
378 else
379 rperp(o, pos) = perp(o, rect.bottomRight()) -
380 perp(o, QSize(margins.bottom(), margins.right())) -
381 (perp(o, hint) - perp(o, margins)) + 1;
382 QSize size;
383 rpick(o, size) = extensionExtent;
384 rperp(o, size) = perp(o, hint) - perp(o, margins);
385 QRect r(pos, size);
386
387 if (o == Qt::Horizontal)
388 r = QStyle::visualRect(parentWidget()->layoutDirection(), rect, r);
389
390 extension->setGeometry(r);
391
392 if (extension->isHidden())
393 extension->show();
394 } else {
395 if (!extension->isHidden())
396 extension->hide();
397 }
398}
399
401{
402 if (dirty)
403 updateGeomArray();
404
405 QRect rect(0, 0, size.width(), size.height());
406
407 QList<QWidget*> showWidgets, hideWidgets;
408
409 QToolBar *tb = qobject_cast<QToolBar*>(parentWidget());
410 if (!tb)
411 return false;
412 QStyle *style = tb->style();
413 QStyleOptionToolBar opt;
414 tb->initStyleOption(&opt);
415 const int handleExtent = movable()
417 const QMargins margins = contentsMargins();
418 const int spacing = this->spacing();
419 const int extensionExtent = style->pixelMetric(QStyle::PM_ToolBarExtensionExtent, &opt, tb);
420 Qt::Orientation o = tb->orientation();
421 bool extensionMenuContainsOnlyWidgetActions = true;
422
423 int space = pick(o, rect.size()) - pick(o, margins) - handleExtent;
424 if (space <= 0)
425 return false; // nothing to do.
426
427 if (popupMenu)
428 popupMenu->clear();
429
430 bool ranOutOfSpace = false;
431 int rows = 0;
432 int rowPos = perp(o, rect.topLeft()) + perp(o, QSize(margins.top(), margins.left()));
433 int i = 0;
434 while (i < items.size()) {
435 QList<QLayoutStruct> a = geomArray;
436
437 int start = i;
438 int size = 0;
439 int prev = -1;
440 int rowHeight = 0;
441 int count = 0;
442 int maximumSize = 0;
443 bool expansiveRow = false;
444 for (; i < items.size(); ++i) {
445 if (a[i].empty)
446 continue;
447
448 int newSize = size + (count == 0 ? 0 : spacing) + a[i].minimumSize;
449 if (prev != -1 && newSize > space) {
450 if (rows == 0)
451 ranOutOfSpace = true;
452 // do we have to move the previous item to the next line to make space for
453 // the extension button?
454 if (count > 1 && size + spacing + extensionExtent > space)
455 i = prev;
456 break;
457 }
458
459 if (expanded)
460 rowHeight = qMax(rowHeight, perp(o, items.at(i)->sizeHint()));
461 expansiveRow = expansiveRow || a[i].expansive;
462 size = newSize;
463 maximumSize += spacing + (a[i].expansive ? a[i].maximumSize : a[i].smartSizeHint());
464 prev = i;
465 ++count;
466 }
467
468 // stretch at the end
469 a[i].sizeHint = 0;
470 a[i].maximumSize = QWIDGETSIZE_MAX;
471 a[i].minimumSize = 0;
472 a[i].expansive = true;
473 a[i].stretch = 0;
474 a[i].empty = true;
475
476 if (expansiveRow && maximumSize < space) {
477 expansiveRow = false;
478 a[i].maximumSize = space - maximumSize;
479 }
480
481 qGeomCalc(a, start, i - start + (expansiveRow ? 0 : 1), 0,
482 space - (ranOutOfSpace ? (extensionExtent + spacing) : 0),
483 spacing);
484
485 for (int j = start; j < i; ++j) {
486 QToolBarItem *item = items.at(j);
487
488 if (a[j].empty) {
489 if (!item->widget()->isHidden())
490 hideWidgets << item->widget();
491 continue;
492 }
493
494 QPoint pos;
495 rpick(o, pos) = pick(o, QSize(margins.top(), margins.left())) + handleExtent + a[j].pos;
496 rperp(o, pos) = rowPos;
497 QSize size;
498 rpick(o, size) = a[j].size;
499 if (expanded)
500 rperp(o, size) = rowHeight;
501 else
502 rperp(o, size) = perp(o, rect.size()) - perp(o, margins);
503 QRect r(pos, size);
504
505 if (o == Qt::Horizontal)
506 r = QStyle::visualRect(parentWidget()->layoutDirection(), rect, r);
507
508 item->setGeometry(r);
509
510 if (item->widget()->isHidden())
511 showWidgets << item->widget();
512 }
513
514 if (!expanded) {
515 for (int j = i; j < items.size(); ++j) {
516 QToolBarItem *item = items.at(j);
517 if (!item->widget()->isHidden())
518 hideWidgets << item->widget();
519 if (popupMenu) {
521 popupMenu->addAction(item->action);
522 extensionMenuContainsOnlyWidgetActions = false;
523 }
524 }
525 }
526 break;
527 }
528
529 rowPos += rowHeight + spacing;
530 ++rows;
531 }
532
533 // if we are using a popup menu, not the expadning toolbar effect, we cannot move custom
534 // widgets into the menu. If only custom widget actions are chopped off, the popup menu
535 // is empty. So we show the little extension button to show something is chopped off,
536 // but we make it disabled.
537 extension->setEnabled(popupMenu == nullptr || !extensionMenuContainsOnlyWidgetActions);
538
539 // we have to do the show/hide here, because it triggers more calls to setGeometry :(
540 for (int i = 0; i < showWidgets.size(); ++i)
541 showWidgets.at(i)->show();
542 for (int i = 0; i < hideWidgets.size(); ++i)
543 hideWidgets.at(i)->hide();
544
545 return ranOutOfSpace;
546}
547
549{
550 if (dirty)
551 updateGeomArray();
552
553 QToolBar *tb = qobject_cast<QToolBar*>(parentWidget());
554 if (!tb)
555 return QSize(0, 0);
556 QMainWindow *win = qobject_cast<QMainWindow*>(tb->parentWidget());
557 Qt::Orientation o = tb->orientation();
558 QStyle *style = tb->style();
559 QStyleOptionToolBar opt;
560 tb->initStyleOption(&opt);
561 const int handleExtent = movable()
563 const QMargins margins = contentsMargins();
564 const int spacing = this->spacing();
565 const int extensionExtent = style->pixelMetric(QStyle::PM_ToolBarExtensionExtent, &opt, tb);
566
567 int total_w = 0;
568 int count = 0;
569 for (int x = 0; x < items.size(); ++x) {
570 if (!geomArray[x].empty) {
571 total_w += (count == 0 ? 0 : spacing) + geomArray[x].minimumSize;
572 ++count;
573 }
574 }
575 if (count == 0)
576 return QSize(0, 0);
577
578 int min_w = pick(o, size);
579 int rows = (int)qSqrt(qreal(count));
580 if (rows == 1)
581 ++rows; // we want to expand to at least two rows
582 int space = total_w/rows + spacing + extensionExtent;
583 space = qMax(space, min_w - pick(o, margins) - handleExtent);
584 if (win != nullptr)
585 space = qMin(space, pick(o, win->size()) - pick(o, margins) - handleExtent);
586
587 int w = 0;
588 int h = 0;
589 int i = 0;
590 while (i < items.size()) {
591 int count = 0;
592 int size = 0;
593 int prev = -1;
594 int rowHeight = 0;
595 for (; i < items.size(); ++i) {
596 if (geomArray[i].empty)
597 continue;
598
599 int newSize = size + (count == 0 ? 0 : spacing) + geomArray[i].minimumSize;
600 rowHeight = qMax(rowHeight, perp(o, items.at(i)->sizeHint()));
601 if (prev != -1 && newSize > space) {
602 if (count > 1 && size + spacing + extensionExtent > space) {
603 size -= spacing + geomArray[prev].minimumSize;
604 i = prev;
605 }
606 break;
607 }
608
609 size = newSize;
610 prev = i;
611 ++count;
612 }
613
614 w = qMax(size, w);
615 h += rowHeight + spacing;
616 }
617
618 w += pick(Qt::Horizontal, margins) + handleExtent + spacing + extensionExtent;
619 w = qMax(w, min_w);
620 if (win != nullptr)
621 w = qMin(w, pick(o, win->size()));
622 h += pick(Qt::Vertical, margins) - spacing; //there is no spacing before the first row
623
625 rpick(o, result) = w;
626 rperp(o, result) = h;
627 return result;
628}
629
631{
632 QWidget *tb = qobject_cast<QToolBar*>(parentWidget());
633 if (!tb)
634 return;
635 if (exp == expanded && !tb->isWindow())
636 return;
637
638 expanded = exp;
639 extension->setChecked(expanded);
640
641 if (QMainWindow *win = qobject_cast<QMainWindow*>(tb->parentWidget())) {
642#if !QT_CONFIG(dockwidget)
643 animating = false;
644#else
645 animating = !tb->isWindow() && win->isAnimated();
646#endif
648 if (expanded) {
649 tb->raise();
650 } else {
651 QList<int> path = layout->layoutState.indexOf(tb);
652 if (!path.isEmpty()) {
653 QRect rect = layout->layoutState.itemRect(path);
654 layoutActions(rect.size());
655 }
656 }
657 layout->layoutState.toolBarAreaLayout.apply(animating);
658 }
659}
660
662{
663 if (dirty)
664 updateGeomArray();
665 return minSize;
666}
667
669{
670 if (dirty)
671 updateGeomArray();
672 return hint;
673}
674
675QToolBarItem *QToolBarLayout::createItem(QAction *action)
676{
677 bool customWidget = false;
678 bool standardButtonWidget = false;
679 QWidget *widget = nullptr;
680 QToolBar *tb = qobject_cast<QToolBar*>(parentWidget());
681 if (!tb)
682 return (QToolBarItem *)nullptr;
683
684 if (QWidgetAction *widgetAction = qobject_cast<QWidgetAction *>(action)) {
685 widget = widgetAction->requestWidget(tb);
686 if (widget != nullptr) {
687 widget->setAttribute(Qt::WA_LayoutUsesWidgetRect);
688 customWidget = true;
689 }
690 } else if (action->isSeparator()) {
692 connect(tb, SIGNAL(orientationChanged(Qt::Orientation)),
693 sep, SLOT(setOrientation(Qt::Orientation)));
694 widget = sep;
695 }
696
697 if (!widget) {
698 QToolButton *button = new QToolButton(tb);
699 button->setAutoRaise(true);
701 button->setIconSize(tb->iconSize());
702 button->setToolButtonStyle(tb->toolButtonStyle());
703 QObject::connect(tb, SIGNAL(iconSizeChanged(QSize)),
704 button, SLOT(setIconSize(QSize)));
705 QObject::connect(tb, SIGNAL(toolButtonStyleChanged(Qt::ToolButtonStyle)),
706 button, SLOT(setToolButtonStyle(Qt::ToolButtonStyle)));
707 button->setDefaultAction(action);
708 QObject::connect(button, SIGNAL(triggered(QAction*)), tb, SIGNAL(actionTriggered(QAction*)));
709 widget = button;
710 standardButtonWidget = true;
711 }
712
713 widget->hide();
715 if (standardButtonWidget)
716 result->setAlignment(Qt::AlignJustify);
717 result->customWidget = customWidget;
718 result->action = action;
719 return result;
720}
721
723
724#include "moc_qtoolbarlayout_p.cpp"
void setIconSize(const QSize &size)
The QAction class provides an abstraction for user commands that can be added to different user inter...
Definition qaction.h:30
bool isSeparator() const
Returns true if this action is a separator action; otherwise it returns false.
Definition qaction.cpp:585
bool isVisible() const
Definition qaction.cpp:1018
void hide()
Hides the item (items are visible by default).
static QPlatformNativeInterface * platformNativeInterface()
The QLayoutItem class provides an abstract item that a QLayout manipulates.
Definition qlayoutitem.h:25
virtual QWidget * widget() const
If this item manages a QWidget, returns that widget.
The QLayout class is the base class of geometry managers.
Definition qlayout.h:26
QRect geometry() const override
\reimp
Definition qlayout.cpp:460
int spacing
the spacing between widgets inside the layout
Definition qlayout.h:30
QSize maximumSize() const override
Returns the maximum size of this layout.
Definition qlayout.cpp:927
virtual void setSpacing(int)
Definition qlayout.cpp:266
QMargins contentsMargins
Definition qlayout.h:32
void invalidate() override
\reimp
Definition qlayout.cpp:469
QWidget * parentWidget() const
Returns the parent widget of this layout, or \nullptr if this layout is not installed on any widget.
Definition qlayout.cpp:399
virtual void setGeometry(const QRect &) override
\reimp
Definition qlayout.cpp:451
QLayout * layout() override
\reimp
virtual int indexOf(const QWidget *) const
Searches for widget widget in this layout (not including child layouts).
Definition qlayout.cpp:1177
void setContentsMargins(int left, int top, int right, int bottom)
Definition qlayout.cpp:288
qsizetype size() const noexcept
Definition qlist.h:397
bool isEmpty() const noexcept
Definition qlist.h:401
iterator insert(qsizetype i, parameter_type t)
Definition qlist.h:488
T takeAt(qsizetype i)
Definition qlist.h:609
const_reference at(qsizetype i) const noexcept
Definition qlist.h:446
value_type takeFirst()
Definition qlist.h:566
The QMainWindow class provides a main application window.
Definition qmainwindow.h:25
\inmodule QtCore
Definition qmargins.h:24
constexpr int bottom() const noexcept
Returns the bottom margin.
Definition qmargins.h:115
constexpr int left() const noexcept
Returns the left margin.
Definition qmargins.h:106
constexpr int right() const noexcept
Returns the right margin.
Definition qmargins.h:112
constexpr int top() const noexcept
Returns the top margin.
Definition qmargins.h:109
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus.
Definition qmenu.h:26
void clear()
Removes all the menu's actions.
Definition qmenu.cpp:2225
void addAction(QAction *action)
Appends the action action to this widget's list of actions.
Definition qwidget.cpp:3117
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
\threadsafe
Definition qobject.cpp:3236
The QPlatformNativeInterface class provides an abstraction for retrieving native resource handles.
virtual NativeResourceForIntegrationFunction nativeResourceFunctionForIntegration(const QByteArray &resource)
\inmodule QtCore\reentrant
Definition qpoint.h:25
constexpr int y() const noexcept
Returns the y coordinate of this point.
Definition qpoint.h:135
\inmodule QtCore\reentrant
Definition qrect.h:30
\inmodule QtCore
Definition qsize.h:25
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI.
Definition qstyle.h:29
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:2143
@ PM_ToolBarHandleExtent
Definition qstyle.h:484
@ PM_ToolBarItemSpacing
Definition qstyle.h:485
@ PM_ToolBarItemMargin
Definition qstyle.h:486
@ PM_ToolBarExtensionExtent
Definition qstyle.h:488
@ PM_ToolBarFrameWidth
Definition qstyle.h:483
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const =0
Returns the value of the given pixel metric.
bool isEmpty() const override
Implemented in subclasses to return whether this item is empty, i.e.
QToolBarItem(QWidget *widget)
void setGeometry(const QRect &r) override
\reimp
QSize sizeHint() const override
Implemented in subclasses to return the preferred size of this item.
bool layoutActions(const QSize &size)
void addItem(QLayoutItem *item) override
Implemented in subclasses to add an item.
QLayoutItem * takeAt(int index) override
Must be implemented in subclasses to remove the layout item at index from the layout,...
int count() const override
Must be implemented in subclasses to return the number of items in the layout.
void updateMacBorderMetrics()
void setUsePopupMenu(bool set)
void insertAction(int index, QAction *action)
bool isEmpty() const override
\reimp
void setExpanded(bool b)
int indexOf(const QAction *action) const
QToolBarLayout(QWidget *parent=nullptr)
void invalidate() override
\reimp
void updateMarginAndSpacing()
QSize expandedSize(const QSize &size) const
bool hasExpandFlag() const
Qt::Orientations expandingDirections() const override
Returns whether this layout can make use of more space than sizeHint().
bool movable() const
QLayoutItem * itemAt(int index) const override
Must be implemented in subclasses to return the layout item at index.
QSize minimumSize() const override
Returns the minimum size of this layout.
The QToolBar class provides a movable panel that contains a set of controls.
Definition qtoolbar.h:23
The QToolButton class provides a quick-access button to commands or options, usually used inside a QT...
Definition qtoolbutton.h:20
The QWidgetAction class extends QAction by an interface for inserting custom widgets into action base...
The QWidgetItem class is a layout item that represents a widget.
Definition qlayoutitem.h:86
QSize sizeHint() const override
\reimp
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
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:886
bool isHidden() const
Returns true if the widget is hidden, otherwise returns false.
Definition qwidget.h:877
QSize size
the size of the widget excluding any window frame
Definition qwidget.h:113
void setEnabled(bool)
Definition qwidget.cpp:3358
void setFocusPolicy(Qt::FocusPolicy policy)
Definition qwidget.cpp:7822
void hide()
Hides the widget.
Definition qwidget.cpp:8135
void show()
Shows the widget and its child widgets.
Definition qwidget.cpp:7875
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition qwidget.h:811
void removeAction(QAction *action)
Removes the action action from this widget's list of actions.
Definition qwidget.cpp:3186
\inmodule QtGui
Definition qwindow.h:63
QOpenGLWidget * widget
[1]
QPushButton * button
[2]
rect
[4]
QStyleOptionButton opt
Combined button and popup list for selecting options.
@ AlignJustify
Definition qnamespace.h:149
@ WA_LayoutUsesWidgetRect
Definition qnamespace.h:365
ToolBarArea
@ LeftToolBarArea
@ TopToolBarArea
@ NoFocus
Definition qnamespace.h:107
Orientation
Definition qnamespace.h:98
@ Horizontal
Definition qnamespace.h:99
@ Vertical
Definition qnamespace.h:100
@ UniqueConnection
ToolButtonStyle
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction function
QMainWindowLayout * qt_mainwindow_layout(const QMainWindow *window)
static int pick(bool vertical, const QSize &size)
static int perp(bool vertical, const QSize &size)
qfloat16 qSqrt(qfloat16 f)
Definition qfloat16.h:289
static int area(const QSize &s)
Definition qicon.cpp:153
void qGeomCalc(QList< QLayoutStruct > &chain, int start, int count, int pos, int space, int spacer)
#define qWarning
Definition qlogging.h:166
static int & rperp(Qt::Orientation o, QPoint &pos)
Definition qmenu_p.h:61
static int & rpick(Qt::Orientation o, QPoint &pos)
Definition qmenu_p.h:46
constexpr const T & qMin(const T &a, const T &b)
Definition qminmax.h:40
constexpr const T & qMax(const T &a, const T &b)
Definition qminmax.h:42
#define SLOT(a)
Definition qobjectdefs.h:52
#define SIGNAL(a)
Definition qobjectdefs.h:53
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint index
[2]
GLboolean r
[2]
GLenum GLenum GLsizei count
GLuint start
GLfloat GLfloat GLfloat GLfloat h
GLdouble s
[6]
Definition qopenglext.h:235
GLsizei const GLchar *const * path
GLuint64EXT * result
[6]
static constexpr QChar sep
static bool defaultWidgetAction(QToolBarItem *item)
QT_BEGIN_NAMESPACE QMainWindowLayout * qt_mainwindow_layout(const QMainWindow *window)
double qreal
Definition qtypes.h:187
#define QWIDGETSIZE_MAX
Definition qwidget.h:917
QWidget * win
Definition settings.cpp:6
QFuture< QSet< QChar > > set
[10]
QObject::connect nullptr
QGraphicsItem * item
aWidget window() -> setWindowTitle("New Window Title")
[2]