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
qgraphicswidget_p.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 "qglobal.h"
5
6#include <QtCore/qdebug.h>
7#include <QtCore/qnumeric.h>
8#include "qgraphicswidget_p.h"
10#include "qgraphicslayout.h"
11#include "qgraphicsscene_p.h"
12#include <QtWidgets/qapplication.h>
13#include <QtWidgets/qgraphicsscene.h>
14#include <QtWidgets/qstyleoption.h>
15#include <QtWidgets/QStyleOptionTitleBar>
16#include <QtWidgets/QGraphicsSceneMouseEvent>
17
19
20void QGraphicsWidgetPrivate::init(QGraphicsItem *parentItem, Qt::WindowFlags wFlags)
21{
22 Q_Q(QGraphicsWidget);
23
24 attributes = 0;
25 isWidget = 1; // QGraphicsItem::isWidget() returns true.
28
29 adjustWindowFlags(&wFlags);
30 windowFlags = wFlags;
31
32 q->setParentItem(parentItem);
34 q->setGraphicsItem(q);
35
37 q->unsetWindowFrameMargins();
42}
43
45{
46 Q_Q(const QGraphicsWidget);
47 int height = q->style()->pixelMetric(QStyle::PM_TitleBarHeight, &options);
48 return (qreal)height;
49}
50
55 : margins(nullptr),
57 inheritedPaletteResolveMask(0),
58 inheritedFontResolveMask(0),
59 inSetGeometry(false),
60 polished(false),
61 inSetPos(false),
62 autoFillBackground(false),
63 focusPolicy(Qt::NoFocus),
64 focusNext(nullptr),
65 focusPrev(nullptr),
66 windowFlags(),
67 windowData(nullptr),
68 setWindowFrameMargins(false),
69 windowFrameMargins(nullptr)
70{
71}
72
76
84{
85 if (!margins)
86 margins = std::make_unique<QMarginsF>();
87}
88
96{
98 windowFrameMargins = std::make_unique<QMarginsF>();
99}
100
108{
109 if (!windowData)
110 windowData = std::make_unique<WindowData>();
111}
112
114{
115 if (this->palette == palette && this->palette.resolveMask() == palette.resolveMask())
116 return;
118}
119
121{
122 inheritedPaletteResolveMask = inheritedMask;
123 QPalette naturalPalette = naturalWidgetPalette();
124 QPalette resolvedPalette = palette.resolve(naturalPalette);
125 updatePalette(resolvedPalette);
126}
127
129{
130 Q_Q(QGraphicsWidget);
131 // Update local palette setting.
132 this->palette = palette;
133
134 // Calculate new mask.
135 if (q->isWindow() && !q->testAttribute(Qt::WA_WindowPropagation))
138
139 // Propagate to children.
140 for (int i = 0; i < children.size(); ++i) {
142 if (item->isWidget()) {
143 QGraphicsWidget *w = static_cast<QGraphicsWidget *>(item);
144 if (!w->isWindow() || w->testAttribute(Qt::WA_WindowPropagation))
145 w->d_func()->resolvePalette(mask);
146 } else {
148 }
149 }
150
151 // Notify change.
154}
155
157{
158 Q_Q(QGraphicsWidget);
160 return;
161 q->setAttribute(Qt::WA_RightToLeft, (direction == Qt::RightToLeft));
162
163 // Propagate this change to all children.
164 for (int i = 0; i < children.size(); ++i) {
166 if (item->isWidget()) {
167 QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item);
169 widget->d_func()->setLayoutDirection_helper(direction);
170 }
171 }
172
173 // Send the notification event to this widget item.
176}
177
179{
180 Q_Q(QGraphicsWidget);
181 if (q->testAttribute(Qt::WA_SetLayoutDirection)) {
182 return;
183 }
184 if (QGraphicsWidget *parentWidget = q->parentWidget()) {
185 setLayoutDirection_helper(parentWidget->layoutDirection());
186 } else if (scene) {
187 // ### shouldn't the scene have a layoutdirection really? how does
188 // ### QGraphicsWidget get changes from QApplication::layoutDirection?
190 } else {
192 }
193}
194
196{
197 Q_Q(const QGraphicsWidget);
200 palette = parent->palette();
201 } else if (scene) {
202 palette = scene->palette();
203 }
205 return palette;
206}
207
209{
210 if (this->font == font && this->font.resolveMask() == font.resolveMask())
211 return;
213}
214
216{
217 Q_Q(QGraphicsWidget);
218 inheritedFontResolveMask = inheritedMask;
220 inheritedFontResolveMask |= p->d_func()->inheritedFontResolveMask;
221 QFont naturalFont = naturalWidgetFont();
222 QFont resolvedFont = font.resolve(naturalFont);
223 updateFont(resolvedFont);
224}
225
227{
228 Q_Q(QGraphicsWidget);
229 // Update the local font setting.
230 this->font = font;
231
232 // Calculate new mask.
233 if (q->isWindow() && !q->testAttribute(Qt::WA_WindowPropagation))
236
237 // Propagate to children.
238 for (int i = 0; i < children.size(); ++i) {
240 if (item->isWidget()) {
241 QGraphicsWidget *w = static_cast<QGraphicsWidget *>(item);
242 if (!w->isWindow() || w->testAttribute(Qt::WA_WindowPropagation))
243 w->d_func()->resolveFont(mask);
244 } else {
246 }
247 }
248
249 if (!polished)
250 return;
251 // Notify change.
254}
255
257{
258 Q_Q(const QGraphicsWidget);
259 QFont naturalFont; // ### no application font support
261 naturalFont = parent->font();
262 } else if (scene) {
263 naturalFont = scene->font();
264 }
265 naturalFont.setResolveMask(0);
266 return naturalFont;
267}
268
270{
271 Q_Q(QGraphicsWidget);
273 q->initStyleOption(option);
274 option->rect.setHeight(titleBarHeight(*option));
275 option->titleBarFlags = windowFlags;
277 option->activeSubControls = windowData->hoveredSubControl;
278 bool isActive = q->isActiveWindow();
279 option->state.setFlag(QStyle::State_Active, isActive);
280 if (isActive) {
281 option->titleBarState = Qt::WindowActive;
282 option->titleBarState |= QStyle::State_Active;
283 } else {
284 option->titleBarState = Qt::WindowNoState;
285 }
286 QFont windowTitleFont = QApplication::font("QMdiSubWindowTitleBar");
287 QRect textRect = q->style()->subControlRect(QStyle::CC_TitleBar, option, QStyle::SC_TitleBarLabel, nullptr);
288 option->text = QFontMetrics(windowTitleFont).elidedText(
289 windowData->windowTitle, Qt::ElideRight, textRect.width());
290}
291
313
315{
316 Q_Q(QGraphicsWidget);
318 if (windowData->grabbedSection != Qt::NoSection) {
319 if (windowData->grabbedSection == Qt::TitleBarArea) {
320 windowData->buttonSunken = false;
323 // make sure that the coordinates (rect and pos) we send to the style are positive.
324 bar.rect = q->windowFrameRect().toRect();
325 bar.rect.moveTo(0,0);
326 bar.rect.setHeight(q->style()->pixelMetric(QStyle::PM_TitleBarHeight, &bar));
327 QPointF pos = event->pos();
328 if (windowFrameMargins) {
329 pos.rx() += windowFrameMargins->left();
330 pos.ry() += windowFrameMargins->top();
331 }
333 if (q->style()->subControlRect(QStyle::CC_TitleBar, &bar,
335 event->widget()).contains(pos.toPoint())) {
336 q->close();
337 }
338 }
339 if (!(static_cast<QGraphicsSceneMouseEvent *>(event)->buttons()))
340 windowData->grabbedSection = Qt::NoSection;
341 event->accept();
342 }
343}
344
346{
347 Q_Q(QGraphicsWidget);
348 if (event->button() != Qt::LeftButton)
349 return;
350
352 windowData->startGeometry = q->geometry();
353 windowData->grabbedSection = q->windowFrameSectionAt(event->pos());
355 if (windowData->grabbedSection == Qt::TitleBarArea
356 && windowData->hoveredSubControl == QStyle::SC_TitleBarCloseButton) {
357 windowData->buttonSunken = true;
358 q->update();
359 }
360 event->setAccepted(windowData->grabbedSection != Qt::NoSection);
361}
362
363/*
364 Used to calculate the
365 Precondition:
366 \a widget should support either hfw or wfh
367
368 If \a heightForWidth is set to false, this function will query the width for height
369 instead. \a width will then be interpreted as height, \a minh and \a maxh will be interpreted
370 as minimum width and maximum width.
371 */
373 const QGraphicsWidget *widget,
374 bool heightForWidth = true)
375{
377 const bool hasHFW = QGraphicsLayoutItemPrivate::get(widget)->hasHeightForWidth();
378 if (hasHFW == heightForWidth) {
379 minimumHeightForWidth = hasHFW
380 ? widget->effectiveSizeHint(Qt::MinimumSize, QSizeF(width, -1)).height()
381 : widget->effectiveSizeHint(Qt::MinimumSize, QSizeF(-1, width)).width(); //"width" is here height!
382 } else {
383 // widthForHeight
384 const qreal constraint = width;
385 while (maxh - minh > 0.1) {
386 qreal middle = minh + (maxh - minh)/2;
387 // ### really bad, if we are a widget with a layout it will call
388 // layout->effectiveSizeHint(Qt::MiniumumSize), which again will call
389 // sizeHint three times because of how the cache works
390 qreal hfw = hasHFW
391 ? widget->effectiveSizeHint(Qt::MinimumSize, QSizeF(middle, -1)).height()
392 : widget->effectiveSizeHint(Qt::MinimumSize, QSizeF(-1, middle)).width();
393 if (hfw > constraint) {
394 minh = middle;
395 } else if (hfw <= constraint) {
396 maxh = middle;
397 }
398 }
400 }
402}
403
405 const QGraphicsWidget *widget)
406{
407 return minimumHeightForWidth(height, minw, maxw, widget, false);
408}
409
410static QSizeF closestAcceptableSize(const QSizeF &proposed,
411 const QGraphicsWidget *widget)
412{
413 const QSizeF current = widget->size();
414
415 qreal minw = proposed.width();
416 qreal maxw = current.width();
417 qreal minh = proposed.height();
418 qreal maxh = current.height();
419
420 qreal middlew = maxw;
421 qreal middleh = maxh;
422 qreal min_hfw;
423 min_hfw = minimumHeightForWidth(maxw, minh, maxh, widget);
424
425 do {
426 if (maxw - minw < 0.1) {
427 // we still haven't found anything, cut off binary search
428 minw = maxw;
429 minh = maxh;
430 }
431 middlew = minw + (maxw - minw)/2.0;
432 middleh = minh + (maxh - minh)/2.0;
433
434 min_hfw = minimumHeightForWidth(middlew, minh, maxh, widget);
435
436 if (min_hfw > middleh) {
437 minw = middlew;
438 minh = middleh;
439 } else if (min_hfw <= middleh) {
440 maxw = middlew;
441 maxh = middleh;
442 }
443 } while (maxw != minw);
444
445 min_hfw = minimumHeightForWidth(middlew, minh, maxh, widget);
446
448 if (min_hfw < maxh) {
449 result = QSizeF(middlew, min_hfw);
450 } else {
451 // Needed because of the cut-off we do above.
452 result = QSizeF(minimumWidthForHeight(maxh, proposed.width(), current.width(), widget), maxh);
453 }
454 return result;
455}
456
457static void _q_boundGeometryToSizeConstraints(const QRectF &startGeometry,
459 const QSizeF &min, const QSizeF &max,
460 const QGraphicsWidget *widget)
461{
462 const QRectF proposedRect = *rect;
463 qreal width = qBound(min.width(), proposedRect.width(), max.width());
464 qreal height = qBound(min.height(), proposedRect.height(), max.height());
465
466 const bool hasHFW = QGraphicsLayoutItemPrivate::get(widget)->hasHeightForWidth();
467 const bool hasWFH = QGraphicsLayoutItemPrivate::get(widget)->hasWidthForHeight();
468
469 const bool widthChanged = proposedRect.width() != widget->size().width();
470 const bool heightChanged = proposedRect.height() != widget->size().height();
471
472 if (hasHFW || hasWFH) {
473 if (widthChanged || heightChanged) {
474 qreal minExtent;
475 qreal maxExtent;
476 qreal constraint;
477 qreal proposed;
478 if (hasHFW) {
479 minExtent = min.height();
480 maxExtent = max.height();
481 constraint = width;
482 proposed = proposedRect.height();
483 } else {
484 // width for height
485 minExtent = min.width();
486 maxExtent = max.width();
487 constraint = height;
488 proposed = proposedRect.width();
489 }
490 if (minimumHeightForWidth(constraint, minExtent, maxExtent, widget, hasHFW) > proposed) {
492 width = effectiveSize.width();
493 height = effectiveSize.height();
494 }
495 }
496 }
497
498 switch (section) {
499 case Qt::LeftSection:
500 rect->setRect(startGeometry.right() - qRound(width), startGeometry.top(),
501 qRound(width), startGeometry.height());
502 break;
504 rect->setRect(startGeometry.right() - qRound(width), startGeometry.bottom() - qRound(height),
506 break;
507 case Qt::TopSection:
508 rect->setRect(startGeometry.left(), startGeometry.bottom() - qRound(height),
509 startGeometry.width(), qRound(height));
510 break;
512 rect->setTop(rect->bottom() - qRound(height));
513 rect->setWidth(qRound(width));
514 break;
515 case Qt::RightSection:
516 rect->setWidth(qRound(width));
517 break;
519 rect->setWidth(qRound(width));
520 rect->setHeight(qRound(height));
521 break;
523 rect->setHeight(qRound(height));
524 break;
526 rect->setRect(startGeometry.right() - qRound(width), startGeometry.top(),
528 break;
529 default:
530 break;
531 }
532}
533
535{
536 Q_Q(QGraphicsWidget);
538 if (!(event->buttons() & Qt::LeftButton) || windowData->hoveredSubControl != QStyle::SC_TitleBarLabel)
539 return;
540
541 QLineF delta(q->mapFromScene(event->buttonDownScenePos(Qt::LeftButton)), event->pos());
542 QLineF parentDelta(q->mapToParent(delta.p1()), q->mapToParent(delta.p2()));
543 QLineF parentXDelta(q->mapToParent(QPointF(delta.p1().x(), 0)), q->mapToParent(QPointF(delta.p2().x(), 0)));
544 QLineF parentYDelta(q->mapToParent(QPointF(0, delta.p1().y())), q->mapToParent(QPointF(0, delta.p2().y())));
545
546 QRectF newGeometry;
547 switch (windowData->grabbedSection) {
548 case Qt::LeftSection:
549 newGeometry = QRectF(windowData->startGeometry.topLeft()
550 + QPointF(parentXDelta.dx(), parentXDelta.dy()),
551 windowData->startGeometry.size() - QSizeF(delta.dx(), delta.dy()));
552 break;
554 newGeometry = QRectF(windowData->startGeometry.topLeft()
555 + QPointF(parentDelta.dx(), parentDelta.dy()),
556 windowData->startGeometry.size() - QSizeF(delta.dx(), delta.dy()));
557 break;
558 case Qt::TopSection:
559 newGeometry = QRectF(windowData->startGeometry.topLeft()
560 + QPointF(parentYDelta.dx(), parentYDelta.dy()),
561 windowData->startGeometry.size() - QSizeF(0, delta.dy()));
562 break;
564 newGeometry = QRectF(windowData->startGeometry.topLeft()
565 + QPointF(parentYDelta.dx(), parentYDelta.dy()),
566 windowData->startGeometry.size() - QSizeF(-delta.dx(), delta.dy()));
567 break;
568 case Qt::RightSection:
569 newGeometry = QRectF(windowData->startGeometry.topLeft(),
570 windowData->startGeometry.size() + QSizeF(delta.dx(), 0));
571 break;
573 newGeometry = QRectF(windowData->startGeometry.topLeft(),
574 windowData->startGeometry.size() + QSizeF(delta.dx(), delta.dy()));
575 break;
577 newGeometry = QRectF(windowData->startGeometry.topLeft(),
578 windowData->startGeometry.size() + QSizeF(0, delta.dy()));
579 break;
581 newGeometry = QRectF(windowData->startGeometry.topLeft()
582 + QPointF(parentXDelta.dx(), parentXDelta.dy()),
583 windowData->startGeometry.size() - QSizeF(delta.dx(), -delta.dy()));
584 break;
585 case Qt::TitleBarArea:
586 newGeometry = QRectF(windowData->startGeometry.topLeft()
587 + QPointF(parentDelta.dx(), parentDelta.dy()),
588 windowData->startGeometry.size());
589 break;
590 case Qt::NoSection:
591 break;
592 }
593
594 if (windowData->grabbedSection != Qt::NoSection) {
595 _q_boundGeometryToSizeConstraints(windowData->startGeometry, &newGeometry,
596 windowData->grabbedSection,
597 q->effectiveSizeHint(Qt::MinimumSize),
598 q->effectiveSizeHint(Qt::MaximumSize),
599 q);
600 q->setGeometry(newGeometry);
601 }
602}
603
605{
606 Q_Q(QGraphicsWidget);
607 if (!hasDecoration())
608 return;
609
611
612 if (q->rect().contains(event->pos())) {
613 if (windowData->buttonMouseOver || windowData->hoveredSubControl != QStyle::SC_None)
615 return;
616 }
617
618 bool wasMouseOver = windowData->buttonMouseOver;
619 QRect oldButtonRect = windowData->buttonRect;
620 windowData->buttonRect = QRect();
621 windowData->buttonMouseOver = false;
622 QPointF pos = event->pos();
624 // make sure that the coordinates (rect and pos) we send to the style are positive.
625 if (windowFrameMargins) {
626 pos.rx() += windowFrameMargins->left();
627 pos.ry() += windowFrameMargins->top();
628 }
630 bar.rect = q->windowFrameRect().toRect();
631 bar.rect.moveTo(0,0);
632 bar.rect.setHeight(int(titleBarHeight(bar)));
633
634 Qt::CursorShape cursorShape = Qt::ArrowCursor;
635 bool needsSetCursorCall = true;
636 switch (q->windowFrameSectionAt(event->pos())) {
639 cursorShape = Qt::SizeFDiagCursor;
640 break;
643 cursorShape = Qt::SizeBDiagCursor;
644 break;
645 case Qt::LeftSection:
646 case Qt::RightSection:
647 cursorShape = Qt::SizeHorCursor;
648 break;
649 case Qt::TopSection:
651 cursorShape = Qt::SizeVerCursor;
652 break;
653 case Qt::TitleBarArea:
654 windowData->buttonRect = q->style()->subControlRect(
656 if (windowData->buttonRect.contains(pos.toPoint()))
657 windowData->buttonMouseOver = true;
658 event->ignore();
659 break;
660 default:
661 needsSetCursorCall = false;
662 event->ignore();
663 }
664#ifndef QT_NO_CURSOR
665 if (needsSetCursorCall)
666 q->setCursor(cursorShape);
667#else
668 Q_UNUSED(needsSetCursorCall);
669 Q_UNUSED(cursorShape);
670#endif
671 // update buttons if we hover over them
672 windowData->hoveredSubControl = q->style()->hitTestComplexControl(QStyle::CC_TitleBar, &bar, pos.toPoint(), nullptr);
673 if (windowData->hoveredSubControl != QStyle::SC_TitleBarCloseButton)
674 windowData->hoveredSubControl = QStyle::SC_TitleBarLabel;
675
676 if (windowData->buttonMouseOver != wasMouseOver) {
677 if (!oldButtonRect.isNull())
678 q->update(QRectF(oldButtonRect).translated(q->windowFrameRect().topLeft()));
679 if (!windowData->buttonRect.isNull())
680 q->update(QRectF(windowData->buttonRect).translated(q->windowFrameRect().topLeft()));
681 }
682}
683
685{
687 Q_Q(QGraphicsWidget);
688 if (hasDecoration()) {
689 // ### restore the cursor, don't override it
690#ifndef QT_NO_CURSOR
691 q->unsetCursor();
692#endif
693
695
696 bool needsUpdate = false;
697 if (windowData->hoveredSubControl == QStyle::SC_TitleBarCloseButton
698 || windowData->buttonMouseOver)
699 needsUpdate = true;
700
701 // update the hover state (of buttons etc...)
702 windowData->hoveredSubControl = QStyle::SC_None;
703 windowData->buttonMouseOver = false;
704 windowData->buttonRect = QRect();
705 if (needsUpdate)
706 q->update(windowData->buttonRect);
707 }
708}
709
714
719{
720 Q_Q(QGraphicsWidget);
722
723 if (q_ptr->isPanel()) {
724 // panels are never a part of their parent's or ancestors' focus
725 // chains. so reparenting a panel is easy; there's nothing to
726 // do.
727 return;
728 }
729
730 // we're not a panel, so find the first widget in the focus chain
731 // (this), and the last (this, or the last widget that is still
732 // a descendent of this). also find the widgets that currently /
733 // before reparenting point to this widgets' focus chain.
734 QGraphicsWidget *focusFirst = q;
735 QGraphicsWidget *focusBefore = focusPrev;
736 QGraphicsWidget *focusLast = focusFirst;
737 QGraphicsWidget *focusAfter = focusNext;
738 do {
739 if (!q->isAncestorOf(focusAfter))
740 break;
741 focusLast = focusAfter;
742 } while ((focusAfter = focusAfter->d_func()->focusNext));
743
744 if (!parent && oldScene && oldScene != newScene && oldScene->d_func()->tabFocusFirst == q) {
745 // detach from old scene's top level focus chain.
746 oldScene->d_func()->tabFocusFirst = (focusAfter != q) ? focusAfter : nullptr;
747 }
748
749 // detach from current focus chain; skip this widget subtree.
750 focusBefore->d_func()->focusNext = focusAfter;
751 if (focusAfter)
752 focusAfter->d_func()->focusPrev = focusBefore;
753
754 if (newParent) {
755 // attach to new parent's focus chain as the last element
756 // in its chain.
757 QGraphicsWidget *newFocusFirst = newParent;
758 QGraphicsWidget *newFocusLast = newFocusFirst;
759 QGraphicsWidget *newFocusAfter = newFocusFirst->d_func()->focusNext;
760 do {
761 if (!newParent->isAncestorOf(newFocusAfter))
762 break;
763 newFocusLast = newFocusAfter;
764 } while ((newFocusAfter = newFocusAfter->d_func()->focusNext));
765
766 newFocusLast->d_func()->focusNext = q;
767 focusLast->d_func()->focusNext = newFocusAfter;
768 if (newFocusAfter)
769 newFocusAfter->d_func()->focusPrev = focusLast;
770 focusPrev = newFocusLast;
771 } else {
772 // no new parent, so just link up our own prev->last widgets.
773 focusPrev = focusLast;
774 focusLast->d_func()->focusNext = q;
775 }
776}
777
779{
780 delete (this->layout);
781 layout = l;
782 if (!l) {
783 Q_Q(QGraphicsWidget);
784 q->updateGeometry();
785 }
786}
787
789{
790 Q_Q(const QGraphicsWidget);
791 return q->geometry().width();
792}
793
795{
796 if (qIsNaN(w))
797 return;
798 Q_Q(QGraphicsWidget);
799 if (q->geometry().width() == w)
800 return;
801
802 q->setGeometry(QRectF(q->x(), q->y(), w, height()));
803}
804
806{
807 Q_Q(QGraphicsWidget);
808 q->setGeometry(QRectF(q->x(), q->y(), 0, height()));
809}
810
812{
813 Q_Q(const QGraphicsWidget);
814 return q->geometry().height();
815}
816
818{
819 if (qIsNaN(h))
820 return;
821 Q_Q(QGraphicsWidget);
822 if (q->geometry().height() == h)
823 return;
824
825 q->setGeometry(QRectF(q->x(), q->y(), width(), h));
826}
827
829{
830 Q_Q(QGraphicsWidget);
831 q->setGeometry(QRectF(q->x(), q->y(), width(), 0));
832}
833
835{
836 if (inSetGeometry)
837 return;
838 Q_Q(QGraphicsWidget);
839 inSetPos = 1;
840 // Ensure setGeometry is called (avoid recursion when setPos is
841 // called from within setGeometry).
842 q->setGeometry(QRectF(pos, q->size()));
843 inSetPos = 0 ;
844}
845
bool isActive
static QFont font()
Returns the default application font.
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
\inmodule QtCore
Definition qcoreevent.h:45
@ LayoutDirectionChange
Definition qcoreevent.h:124
@ FontChange
Definition qcoreevent.h:133
@ PaletteChange
Definition qcoreevent.h:94
\reentrant \inmodule QtGui
QString elidedText(const QString &text, Qt::TextElideMode mode, int width, int flags=0) const
\reentrant
Definition qfont.h:22
QFont resolve(const QFont &) const
Returns a new QFont that has attributes copied from other that have not been previously set on this f...
Definition qfont.cpp:1893
void setResolveMask(uint mask)
Definition qfont.h:313
uint resolveMask() const
Definition qfont.h:312
QGraphicsScene * scene
QList< QGraphicsItem * > children
QGraphicsItem * parent
virtual void resolvePalette(uint inheritedMask)
QGraphicsItem * q_ptr
virtual void resolveFont(uint inheritedMask)
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
bool isWidget() const
QScopedPointer< QGraphicsItemPrivate > d_ptr
QGraphicsWidget * parentWidget() const
@ ItemUsesExtendedStyleOption
bool isPanel() const
bool isAncestorOf(const QGraphicsItem *child) const
Returns true if this item is an ancestor of child (i.e., if this item is child's parent,...
static QGraphicsLayoutItemPrivate * get(QGraphicsLayoutItem *q)
The QGraphicsLayout class provides the base class for all layouts in Graphics View.
The QGraphicsSceneHoverEvent class provides hover events in the graphics view framework.
The QGraphicsSceneMouseEvent class provides mouse events in the graphics view framework.
The QGraphicsScene class provides a surface for managing a large number of 2D graphical items.
QPalette palette
the scene's default palette
QFont font
the scene's default font
void windowFrameHoverLeaveEvent(QGraphicsSceneHoverEvent *event)
void setFont_helper(const QFont &font)
QGraphicsWidget * focusPrev
void windowFrameHoverMoveEvent(QGraphicsSceneHoverEvent *event)
std::unique_ptr< QMarginsF > margins
void setWidth(qreal) override
void ensureWindowFrameMargins() const
QGraphicsLayout * layout
void updatePalette(const QPalette &palette)
void setLayoutDirection_helper(Qt::LayoutDirection direction)
qreal height() const override
std::unique_ptr< WindowData > windowData
void windowFrameMouseMoveEvent(QGraphicsSceneMouseEvent *event)
bool testAttribute(Qt::WidgetAttribute att) const
qreal titleBarHeight(const QStyleOptionTitleBar &options) const
void updateFont(const QFont &font)
void resolveFont(uint inheritedMask) override
void fixFocusChainBeforeReparenting(QGraphicsWidget *newParent, QGraphicsScene *oldScene, QGraphicsScene *newScene=nullptr)
void setHeight(qreal) override
void init(QGraphicsItem *parentItem, Qt::WindowFlags wFlags)
void initStyleOptionTitleBar(QStyleOptionTitleBar *option)
QPalette naturalWidgetPalette() const
void setPalette_helper(const QPalette &palette)
qreal width() const override
void windowFrameMousePressEvent(QGraphicsSceneMouseEvent *event)
void resolvePalette(uint inheritedMask) override
std::unique_ptr< QMarginsF > windowFrameMargins
void setLayout_helper(QGraphicsLayout *l)
void adjustWindowFlags(Qt::WindowFlags *wFlags)
QGraphicsWidget * focusNext
void windowFrameMouseReleaseEvent(QGraphicsSceneMouseEvent *event)
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.
Qt::LayoutDirection layoutDirection
the default layout direction for this application
\inmodule QtCore\compares equality \compareswith equality QLine \endcompareswith
Definition qline.h:192
constexpr QPointF p1() const
Returns the line's start point.
Definition qline.h:317
constexpr qreal dx() const
Returns the horizontal component of the line's vector.
Definition qline.h:327
constexpr qreal dy() const
Returns the vertical component of the line's vector.
Definition qline.h:332
constexpr QPointF p2() const
Returns the line's end point.
Definition qline.h:322
qsizetype size() const noexcept
Definition qlist.h:397
const_reference at(qsizetype i) const noexcept
Definition qlist.h:446
The QPalette class contains color groups for each widget state.
Definition qpalette.h:19
void setResolveMask(ResolveMask mask)
ResolveMask resolveMask() const
Definition qpalette.cpp:999
QPalette resolve(const QPalette &other) const
Returns a new QPalette that is a union of this instance and other.
Definition qpalette.cpp:963
\inmodule QtCore\reentrant
Definition qpoint.h:217
constexpr qreal & ry() noexcept
Returns a reference to the y coordinate of this point.
Definition qpoint.h:368
constexpr qreal & rx() noexcept
Returns a reference to the x coordinate of this point.
Definition qpoint.h:363
constexpr QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
Definition qpoint.h:404
\inmodule QtCore\reentrant
Definition qrect.h:484
constexpr qreal bottom() const noexcept
Returns the y-coordinate of the rectangle's bottom edge.
Definition qrect.h:500
constexpr qreal height() const noexcept
Returns the height of the rectangle.
Definition qrect.h:732
constexpr qreal width() const noexcept
Returns the width of the rectangle.
Definition qrect.h:729
constexpr QRectF translated(qreal dx, qreal dy) const noexcept
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis,...
Definition qrect.h:762
constexpr qreal left() const noexcept
Returns the x-coordinate of the rectangle's left edge.
Definition qrect.h:497
constexpr qreal top() const noexcept
Returns the y-coordinate of the rectangle's top edge.
Definition qrect.h:498
constexpr qreal right() const noexcept
Returns the x-coordinate of the rectangle's right edge.
Definition qrect.h:499
\inmodule QtCore\reentrant
Definition qrect.h:30
constexpr int width() const noexcept
Returns the width of the rectangle.
Definition qrect.h:236
constexpr void setHeight(int h) noexcept
Sets the height of the rectangle to the given height.
Definition qrect.h:384
constexpr void moveTo(int x, int t) noexcept
Moves the rectangle, leaving the top-left corner at the given position (x, y).
Definition qrect.h:270
\inmodule QtCore
Definition qsize.h:208
constexpr qreal width() const noexcept
Returns the width.
Definition qsize.h:332
constexpr qreal height() const noexcept
Returns the height.
Definition qsize.h:335
The QSizePolicy class is a layout attribute describing horizontal and vertical resizing policy.
Definition qsizepolicy.h:18
constexpr int height() const noexcept
Returns the height.
Definition qsize.h:133
constexpr int width() const noexcept
Returns the width.
Definition qsize.h:130
QStyle::SubControls subControls
\variable QStyleOptionToolBox::selectedPosition
@ State_Active
Definition qstyle.h:83
@ PM_TitleBarHeight
Definition qstyle.h:448
@ CC_TitleBar
Definition qstyle.h:337
@ SC_TitleBarLabel
Definition qstyle.h:384
@ SC_None
Definition qstyle.h:348
@ SC_TitleBarSysMenu
Definition qstyle.h:376
@ SC_TitleBarCloseButton
Definition qstyle.h:379
QSize size
the size of the widget excluding any window frame
Definition qwidget.h:113
int width
the width of the widget excluding any window frame
Definition qwidget.h:114
int height
the height of the widget excluding any window frame
Definition qwidget.h:115
QWidget * parentWidget() const
Returns the parent of this widget, or \nullptr if it does not have any parent widget.
Definition qwidget.h:904
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition qwidget.h:910
QOpenGLWidget * widget
[1]
rect
[4]
direction
QRect textRect
Combined button and popup list for selecting options.
Definition qcompare.h:63
@ WindowNoState
Definition qnamespace.h:252
@ WindowActive
Definition qnamespace.h:256
@ LeftButton
Definition qnamespace.h:58
@ WA_SetLayoutDirection
Definition qnamespace.h:323
@ WA_WindowPropagation
Definition qnamespace.h:349
@ WA_RightToLeft
Definition qnamespace.h:322
LayoutDirection
@ RightToLeft
@ NoFocus
Definition qnamespace.h:107
CursorShape
@ SizeHorCursor
@ SizeVerCursor
@ SizeFDiagCursor
@ ArrowCursor
@ SizeBDiagCursor
WindowFrameSection
@ LeftSection
@ NoSection
@ BottomSection
@ TopRightSection
@ TopLeftSection
@ TitleBarArea
@ BottomLeftSection
@ BottomRightSection
@ TopSection
@ RightSection
@ CustomizeWindowHint
Definition qnamespace.h:239
@ FramelessWindowHint
Definition qnamespace.h:225
@ WindowContextHelpButtonHint
Definition qnamespace.h:231
@ WindowType_Mask
Definition qnamespace.h:220
@ Window
Definition qnamespace.h:207
@ WindowMaximizeButtonHint
Definition qnamespace.h:229
@ WindowMinimizeButtonHint
Definition qnamespace.h:228
@ Dialog
Definition qnamespace.h:208
@ Sheet
Definition qnamespace.h:209
@ SubWindow
Definition qnamespace.h:216
@ Tool
Definition qnamespace.h:212
@ WindowTitleHint
Definition qnamespace.h:226
@ WindowSystemMenuHint
Definition qnamespace.h:227
@ MaximumSize
@ MinimumSize
@ ElideRight
Definition qnamespace.h:190
bool qIsNaN(qfloat16 f) noexcept
Definition qfloat16.h:284
int qRound(qfloat16 d) noexcept
Definition qfloat16.h:327
static void _q_boundGeometryToSizeConstraints(const QRectF &startGeometry, QRectF *rect, Qt::WindowFrameSection section, const QSizeF &min, const QSizeF &max, const QGraphicsWidget *widget)
static qreal minimumHeightForWidth(qreal width, qreal minh, qreal maxh, const QGraphicsWidget *widget, bool heightForWidth=true)
static qreal minimumWidthForHeight(qreal height, qreal minw, qreal maxw, const QGraphicsWidget *widget)
static QSizeF closestAcceptableSize(const QSizeF &proposed, const QGraphicsWidget *widget)
constexpr const T & qBound(const T &min, const T &val, const T &max)
Definition qminmax.h:44
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLint GLsizei width
GLenum type
GLbitfield flags
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
GLfloat GLfloat GLfloat GLfloat h
struct _cl_event * event
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLuint64EXT * result
[6]
GLfloat GLfloat p
[1]
GLuint GLenum option
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
#define Q_UNUSED(x)
unsigned int uint
Definition qtypes.h:34
double qreal
Definition qtypes.h:187
QObject::connect nullptr
QVBoxLayout * layout
QGraphicsItem * item