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
qtooltip.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 <QtWidgets/private/qtwidgetsglobal_p.h>
5
6#include <qapplication.h>
7#include <qevent.h>
8#include <qpointer.h>
9#include <qstyle.h>
10#include <qstyleoption.h>
11#include <qstylepainter.h>
12#include <qtimer.h>
13#if QT_CONFIG(effects)
14#include <private/qeffects_p.h>
15#endif
16#include <qtextdocument.h>
17#include <qdebug.h>
18#include <qpa/qplatformscreen.h>
19#include <qpa/qplatformcursor.h>
20#include <private/qstylesheetstyle_p.h>
21
22#include <qlabel.h>
23#include <QtWidgets/private/qlabel_p.h>
24#include <QtGui/private/qhighdpiscaling_p.h>
25#include <qtooltip.h>
26
28
29using namespace Qt::StringLiterals;
30
90class QTipLabel : public QLabel
91{
93public:
94 QTipLabel(const QString &text, const QPoint &pos, QWidget *w, int msecDisplayTime);
95 ~QTipLabel();
97
99 void updateSize(const QPoint &pos);
100
101 bool eventFilter(QObject *, QEvent *) override;
102
104
106
107 void reuseTip(const QString &text, int msecDisplayTime, const QPoint &pos);
108 void hideTip();
109 void hideTipImmediately();
110 void setTipRect(QWidget *w, const QRect &r);
111 void restartExpireTimer(int msecDisplayTime);
112 bool tipChanged(const QPoint &pos, const QString &text, QObject *o);
113 void placeTip(const QPoint &pos, QWidget *w);
114
115 static QScreen *getTipScreen(const QPoint &pos, QWidget *w);
116protected:
117 void timerEvent(QTimerEvent *e) override;
118 void paintEvent(QPaintEvent *e) override;
119 void mouseMoveEvent(QMouseEvent *e) override;
120 void resizeEvent(QResizeEvent *e) override;
121
122#ifndef QT_NO_STYLE_STYLESHEET
123public slots:
128 setProperty("_q_stylesheet_parent", QVariant());
129 styleSheetParent = nullptr;
130 }
131
132private:
133 QWidget *styleSheetParent;
134#endif
135
136private:
137 QWidget *widget;
138 QRect rect;
139};
140
142
143QTipLabel::QTipLabel(const QString &text, const QPoint &pos, QWidget *w, int msecDisplayTime)
144 : QLabel(w, Qt::ToolTip | Qt::BypassGraphicsProxyWidget)
145#ifndef QT_NO_STYLE_STYLESHEET
146 , styleSheetParent(nullptr)
147#endif
148 , widget(nullptr)
149{
150 delete instance;
151 instance = this;
156 setMargin(1 + style()->pixelMetric(QStyle::PM_ToolTipLabelFrameWidth, nullptr, this));
159 setIndent(1);
160 qApp->installEventFilter(this);
161 setWindowOpacity(style()->styleHint(QStyle::SH_ToolTipLabel_Opacity, nullptr, this) / 255.0);
162 setMouseTracking(true);
163 fadingOut = false;
164 reuseTip(text, msecDisplayTime, pos);
165}
166
167void QTipLabel::restartExpireTimer(int msecDisplayTime)
168{
169 Q_D(const QLabel);
170 const qsizetype textLength = d->needTextControl() ? d->control->toPlainText().size() : text().size();
171 qsizetype time = 10000 + 40 * qMax(0, textLength - 100);
172 if (msecDisplayTime > 0)
173 time = msecDisplayTime;
174 expireTimer.start(time, this);
175 hideTimer.stop();
176}
177
178void QTipLabel::reuseTip(const QString &text, int msecDisplayTime, const QPoint &pos)
179{
180#ifndef QT_NO_STYLE_STYLESHEET
181 if (styleSheetParent){
182 disconnect(styleSheetParent, &QWidget::destroyed,
184 styleSheetParent = nullptr;
185 }
186#endif
187
188 setText(text);
190 restartExpireTimer(msecDisplayTime);
191}
192
194{
195 d_func()->setScreenForPoint(pos);
196 // Ensure that we get correct sizeHints by placing this window on the right screen.
197 QFontMetrics fm(font());
198 QSize extra(1, 0);
199 // Make it look good with the default ToolTip font on Mac, which has a small descent.
200 if (fm.descent() == 2 && fm.ascent() >= 11)
201 ++extra.rheight();
203 QSize sh = sizeHint();
204 const QScreen *screen = getTipScreen(pos, this);
205 if (!wordWrap() && sh.width() > screen->geometry().width()) {
206 setWordWrap(true);
207 sh = sizeHint();
208 }
209 resize(sh + extra);
210}
211
213{
214 QStylePainter p(this);
216 opt.initFrom(this);
217 p.drawPrimitive(QStyle::PE_PanelTipLabel, opt);
218 p.end();
219
221}
222
224{
225 QStyleHintReturnMask frameMask;
227 option.initFrom(this);
228 if (style()->styleHint(QStyle::SH_ToolTip_Mask, &option, this, &frameMask))
229 setMask(frameMask.region);
230
232}
233
235{
236 if (!rect.isNull()) {
238 if (widget)
239 pos = widget->mapFromGlobal(pos);
240 if (!rect.contains(pos))
241 hideTip();
242 }
244}
245
247{
248 instance = nullptr;
249}
250
252{
253 if (!hideTimer.isActive())
254 hideTimer.start(300, this);
255}
256
258{
259 close(); // to trigger QEvent::Close which stops the animation
260 deleteLater();
261}
262
264{
265 if (Q_UNLIKELY(!r.isNull() && !w)) {
266 qWarning("QToolTip::setTipRect: Cannot pass null widget if rect is set");
267 return;
268 }
269 widget = w;
270 rect = r;
271}
272
274{
275 if (e->timerId() == hideTimer.timerId()
276 || e->timerId() == expireTimer.timerId()){
277 hideTimer.stop();
280 }
281}
282
284{
285 switch (e->type()) {
286#ifdef Q_OS_MACOS
287 case QEvent::KeyPress:
288 case QEvent::KeyRelease: {
289 const int key = static_cast<QKeyEvent *>(e)->key();
290 // Anything except key modifiers or caps-lock, etc.
291 if (key < Qt::Key_Shift || key > Qt::Key_ScrollLock)
293 break;
294 }
295#endif
296 case QEvent::Leave:
297 hideTip();
298 break;
299
300
301#if defined (Q_OS_QNX) || defined (Q_OS_WASM) // On QNX the window activate and focus events are delayed and will appear
302 // after the window is shown.
304 case QEvent::FocusIn:
305 return false;
307 if (o != this)
308 return false;
310 break;
311 case QEvent::FocusOut:
312 if (reinterpret_cast<QWindow*>(o) != windowHandle())
313 return false;
315 break;
316#else
319 case QEvent::FocusIn:
320 case QEvent::FocusOut:
321#endif
325 case QEvent::Wheel:
327 break;
328
330 if (o == widget && !rect.isNull() && !rect.contains(static_cast<QMouseEvent*>(e)->position().toPoint()))
331 hideTip();
332 break;
333 default:
334 break;
335 }
336 return false;
337}
338
340{
341 QScreen *guess = w ? w->screen() : QGuiApplication::primaryScreen();
342 QScreen *exact = guess->virtualSiblingAt(pos);
343 return exact ? exact : guess;
344}
345
347{
348#ifndef QT_NO_STYLE_STYLESHEET
349 if (testAttribute(Qt::WA_StyleSheet) || (w && qt_styleSheet(w->style()))) {
350 //the stylesheet need to know the real parent
351 QTipLabel::instance->setProperty("_q_stylesheet_parent", QVariant::fromValue(w));
352 //we force the style to be the QStyleSheetStyle, and force to clear the cache as well.
353 QTipLabel::instance->setStyleSheet("/* */"_L1);
354
355 // Set up for cleaning up this later...
356 QTipLabel::instance->styleSheetParent = w;
357 if (w) {
360 }
361 // QTBUG-64550: A font inherited by the style sheet might change the size,
362 // particular on Windows, where the tip is not parented on a window.
363 // The updatesSize() also makes sure that the content size be updated with
364 // correct content margin.
365 QTipLabel::instance->updateSize(pos);
366 }
367#endif //QT_NO_STYLE_STYLESHEET
368
369 QPoint p = pos;
370 const QScreen *screen = getTipScreen(pos, w);
371 // a QScreen's handle *should* never be null, so this is a bit paranoid
372 if (const QPlatformScreen *platformScreen = screen ? screen->handle() : nullptr) {
373 QPlatformCursor *cursor = platformScreen->cursor();
374 // default implementation of QPlatformCursor::size() returns QSize(16, 16)
375 const QSize nativeSize = cursor ? cursor->size() : QSize(16, 16);
376 const QSize cursorSize = QHighDpi::fromNativePixels(nativeSize,
377 platformScreen);
378 QPoint offset(2, cursorSize.height());
379 // assuming an arrow shape, we can just move to the side for very large cursors
380 if (cursorSize.height() > 2 * this->height())
381 offset = QPoint(cursorSize.width() / 2, 0);
382
383 p += offset;
384
385 QRect screenRect = screen->geometry();
386 if (p.x() + this->width() > screenRect.x() + screenRect.width())
387 p.rx() -= 4 + this->width();
388 if (p.y() + this->height() > screenRect.y() + screenRect.height())
389 p.ry() -= 24 + this->height();
390 if (p.y() < screenRect.y())
391 p.setY(screenRect.y());
392 if (p.x() + this->width() > screenRect.x() + screenRect.width())
393 p.setX(screenRect.x() + screenRect.width() - this->width());
394 if (p.x() < screenRect.x())
395 p.setX(screenRect.x());
396 if (p.y() + this->height() > screenRect.y() + screenRect.height())
397 p.setY(screenRect.y() + screenRect.height() - this->height());
398 }
399 this->move(p);
400}
401
403{
404 if (QTipLabel::instance->text() != text)
405 return true;
406
407 if (o != widget)
408 return true;
409
410 if (!rect.isNull())
411 return !rect.contains(pos);
412 else
413 return false;
414}
415
439void QToolTip::showText(const QPoint &pos, const QString &text, QWidget *w, const QRect &rect, int msecDisplayTime)
440{
441 if (QTipLabel::instance && QTipLabel::instance->isVisible()) { // a tip does already exist
442 if (text.isEmpty()){ // empty text means hide current tip
443 QTipLabel::instance->hideTip();
444 return;
445 } else if (!QTipLabel::instance->fadingOut) {
446 // If the tip has changed, reuse the one
447 // that is showing (removes flickering)
448 QPoint localPos = pos;
449 if (w)
450 localPos = w->mapFromGlobal(pos);
451 if (QTipLabel::instance->tipChanged(localPos, text, w)){
452 QTipLabel::instance->reuseTip(text, msecDisplayTime, pos);
453 QTipLabel::instance->setTipRect(w, rect);
454 QTipLabel::instance->placeTip(pos, w);
455 }
456 return;
457 }
458 }
459
460 if (!text.isEmpty()) { // no tip can be reused, create new tip:
461 QWidget *tipLabelParent = [w]() -> QWidget* {
462#ifdef Q_OS_WIN32
463 // On windows, we can't use the widget as parent otherwise the window will be
464 // raised when the tooltip will be shown
465 Q_UNUSED(w);
466 return nullptr;
467#else
468 return w;
469#endif
470 }();
471 new QTipLabel(text, pos, tipLabelParent, msecDisplayTime); // sets QTipLabel::instance to itself
473 QTipLabel::instance->setTipRect(w, rect);
474 QTipLabel::instance->placeTip(pos, w);
475 QTipLabel::instance->setObjectName("qtooltip_label"_L1);
476
477#if QT_CONFIG(effects)
482 else
483 QTipLabel::instance->showNormal();
484#else
485 QTipLabel::instance->showNormal();
486#endif
487 }
488}
489
509{
510 return (QTipLabel::instance != nullptr && QTipLabel::instance->isVisible());
511}
512
520{
522 return QTipLabel::instance->text();
523 return QString();
524}
525
526
527Q_GLOBAL_STATIC(QPalette, tooltip_palette)
528
529
536{
537 return *tooltip_palette();
538}
539
546{
547 return QApplication::font("QTipLabel");
548}
549
559{
560 *tooltip_palette() = palette;
562 QTipLabel::instance->setPalette(palette);
563}
564
571{
572 QApplication::setFont(font, "QTipLabel");
573}
574
576
577#include "qtooltip.moc"
static bool isEffectEnabled(Qt::UIEffect)
Returns true if effect is enabled; otherwise returns false.
static QFont font()
Returns the default application font.
static void setFont(const QFont &, const char *className=nullptr)
Changes the default application font to font.
\inmodule QtCore
Definition qbasictimer.h:18
void start(int msec, QObject *obj)
\obsolete Use chrono overload instead.
int timerId() const noexcept
Returns the timer's ID.
Definition qbasictimer.h:35
void stop()
Stops the timer.
bool isActive() const noexcept
Returns true if the timer is running and has not been stopped; otherwise returns false.
Definition qbasictimer.h:34
\inmodule QtCore
Definition qcoreevent.h:45
@ FocusOut
Definition qcoreevent.h:67
@ KeyRelease
Definition qcoreevent.h:65
@ MouseMove
Definition qcoreevent.h:63
@ KeyPress
Definition qcoreevent.h:64
@ FocusIn
Definition qcoreevent.h:66
@ MouseButtonPress
Definition qcoreevent.h:60
@ WindowActivate
Definition qcoreevent.h:83
@ MouseButtonDblClick
Definition qcoreevent.h:62
@ WindowDeactivate
Definition qcoreevent.h:84
@ MouseButtonRelease
Definition qcoreevent.h:61
Type type() const
Returns the event type.
Definition qcoreevent.h:304
\reentrant \inmodule QtGui
\reentrant
Definition qfont.h:22
void setFrameStyle(int)
Sets the frame style to style.
Definition qframe.cpp:300
@ NoFrame
Definition qframe.h:39
QScreen * primaryScreen
the primary (or default) screen of the application.
The QKeyEvent class describes a key event.
Definition qevent.h:424
The QLabel widget provides a text or image display.
Definition qlabel.h:20
void setText(const QString &)
Definition qlabel.cpp:263
friend class QTipLabel
Definition qlabel.h:133
void setMargin(int)
Definition qlabel.cpp:541
void paintEvent(QPaintEvent *) override
\reimp
Definition qlabel.cpp:1001
void setIndent(int)
Definition qlabel.cpp:510
void setAlignment(Qt::Alignment)
Definition qlabel.cpp:442
void setWordWrap(bool on)
Definition qlabel.cpp:472
bool wordWrap
the label's word-wrapping policy
Definition qlabel.h:27
QString text
the label's text
Definition qlabel.h:22
void mouseMoveEvent(QMouseEvent *ev) override
\reimp
Definition qlabel.cpp:867
QSize sizeHint() const override
\reimp
Definition qlabel.cpp:820
\inmodule QtGui
Definition qevent.h:196
\inmodule QtCore
Definition qobject.h:103
void destroyed(QObject *=nullptr)
This signal is emitted immediately before the object obj is destroyed, after any instances of QPointe...
void deleteLater()
\threadsafe
Definition qobject.cpp:2435
The QPaintEvent class contains event parameters for paint events.
Definition qevent.h:486
The QPalette class contains color groups for each widget state.
Definition qpalette.h:19
@ ToolTipBase
Definition qpalette.h:57
@ ToolTipText
Definition qpalette.h:57
The QPlatformCursor class provides information about pointer device events (movement,...
The QPlatformScreen class provides an abstraction for visual displays.
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 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
constexpr int height() const noexcept
Returns the height of the rectangle.
Definition qrect.h:239
constexpr bool isNull() const noexcept
Returns true if the rectangle is a null rectangle, otherwise returns false.
Definition qrect.h:164
bool contains(const QRect &r, bool proper=false) const noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qrect.cpp:855
constexpr int x() const noexcept
Returns the x-coordinate of the rectangle's left edge.
Definition qrect.h:185
constexpr int width() const noexcept
Returns the width of the rectangle.
Definition qrect.h:236
constexpr int y() const noexcept
Returns the y-coordinate of the rectangle's top edge.
Definition qrect.h:188
The QResizeEvent class contains event parameters for resize events.
Definition qevent.h:548
The QScreen class is used to query screen properties. \inmodule QtGui.
Definition qscreen.h:32
QRect geometry
the screen's geometry in pixels
Definition qscreen.h:45
QScreen * virtualSiblingAt(QPoint point)
Returns the screen at point within the set of \l QScreen::virtualSiblings(), or nullptr if outside of...
Definition qscreen.cpp:629
QPlatformScreen * handle() const
Get the platform screen handle.
Definition qscreen.cpp:83
QPointF globalPosition() const
Returns the position of the point in this event on the screen or virtual desktop.
Definition qevent.h:123
QPointF position() const
Returns the position of the point in this event, relative to the widget or item that received the eve...
Definition qevent.h:119
\inmodule QtCore
Definition qsize.h:25
constexpr int width() const noexcept
Returns the width.
Definition qsize.h:130
constexpr int & rheight() noexcept
Returns a reference to the height.
Definition qsize.h:157
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
qsizetype size() const noexcept
Returns the number of characters in this string.
Definition qstring.h:186
The QStyleHintReturnMask class provides style hints that return a QRegion.
\variable QStyleOptionFocusRect::backgroundColor
The QStyleOption class stores the parameters used by QStyle functions.
void initFrom(const QWidget *w)
The QStylePainter class is a convenience class for drawing QStyle elements inside a widget.
@ SH_ToolTipLabel_Opacity
Definition qstyle.h:631
@ SH_ToolTip_Mask
Definition qstyle.h:660
@ PM_ToolTipLabelFrameWidth
Definition qstyle.h:501
@ PE_PanelTipLabel
Definition qstyle.h:143
\inmodule QtCore
Definition qcoreevent.h:366
int timerId() const
Returns the unique timer identifier, which is the same identifier as returned from QObject::startTime...
Definition qcoreevent.h:370
void reuseTip(const QString &text, int msecDisplayTime, const QPoint &pos)
Definition qtooltip.cpp:178
void restartExpireTimer(int msecDisplayTime)
Definition qtooltip.cpp:167
void hideTip()
Definition qtooltip.cpp:251
void resizeEvent(QResizeEvent *e) override
This event handler can be reimplemented in a subclass to receive widget resize events which are passe...
Definition qtooltip.cpp:223
void mouseMoveEvent(QMouseEvent *e) override
\reimp
Definition qtooltip.cpp:234
void styleSheetParentDestroyed()
Definition qtooltip.cpp:127
void hideTipImmediately()
Definition qtooltip.cpp:257
bool tipChanged(const QPoint &pos, const QString &text, QObject *o)
Definition qtooltip.cpp:402
void setTipRect(QWidget *w, const QRect &r)
Definition qtooltip.cpp:263
bool fadingOut
Definition qtooltip.cpp:105
QBasicTimer expireTimer
Definition qtooltip.cpp:103
void paintEvent(QPaintEvent *e) override
\reimp
Definition qtooltip.cpp:212
QBasicTimer hideTimer
Definition qtooltip.cpp:103
void timerEvent(QTimerEvent *e) override
This event handler can be reimplemented in a subclass to receive timer events for the object.
Definition qtooltip.cpp:273
void placeTip(const QPoint &pos, QWidget *w)
Definition qtooltip.cpp:346
static QScreen * getTipScreen(const QPoint &pos, QWidget *w)
Definition qtooltip.cpp:339
static QTipLabel * instance
Definition qtooltip.cpp:96
bool eventFilter(QObject *, QEvent *) override
Filters events if this object has been installed as an event filter for the watched object.
Definition qtooltip.cpp:283
void adjustTooltipScreen(const QPoint &pos)
void updateSize(const QPoint &pos)
Definition qtooltip.cpp:193
The QToolTip class provides tool tips (balloon help) for any widget.
Definition qtooltip.h:14
static QPalette palette()
Returns the palette used to render tooltips.
Definition qtooltip.cpp:535
static bool isVisible()
Definition qtooltip.cpp:508
static QFont font()
Definition qtooltip.cpp:545
static QString text()
Definition qtooltip.cpp:519
static void setFont(const QFont &)
Definition qtooltip.cpp:570
static void showText(const QPoint &pos, const QString &text, QWidget *w=nullptr, const QRect &rect={}, int msecShowTime=-1)
Shows text as a tool tip, with the global position pos as the point of interest.
Definition qtooltip.cpp:439
static void setPalette(const QPalette &)
Definition qtooltip.cpp:558
\inmodule QtCore
Definition qvariant.h:65
static auto fromValue(T &&value) noexcept(std::is_nothrow_copy_constructible_v< T > &&Private::CanUseInternalSpace< T >) -> std::enable_if_t< std::conjunction_v< std::is_copy_constructible< T >, std::is_destructible< T > >, QVariant >
Definition qvariant.h:536
static QWidgetPrivate * get(QWidget *w)
Definition qwidget_p.h:212
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
void setBackgroundRole(QPalette::ColorRole)
Sets the background role of the widget to role.
Definition qwidget.cpp:4391
void setMask(const QBitmap &)
Causes only the pixels of the widget for which bitmap has a corresponding 1 bit to be visible.
void setWindowOpacity(qreal level)
void setPalette(const QPalette &)
Definition qwidget.cpp:4530
int width
the width of the widget excluding any window frame
Definition qwidget.h:114
void setMouseTracking(bool enable)
Definition qwidget.h:853
QPoint pos
the position of the widget within its parent widget
Definition qwidget.h:111
bool close()
Closes this widget.
Definition qwidget.cpp:8562
void move(int x, int y)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qwidget.h:880
int height
the height of the widget excluding any window frame
Definition qwidget.h:115
void ensurePolished() const
Ensures that the widget and its children have been polished by QStyle (i.e., have a proper font and p...
QWindow * windowHandle() const
If this is a native widget, return the associated QWindow.
Definition qwidget.cpp:2483
QStyle * style() const
Definition qwidget.cpp:2600
QFont font
the font currently set for the widget
Definition qwidget.h:133
void resize(int w, int h)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qwidget.h:883
virtual void resizeEvent(QResizeEvent *event)
This event handler can be reimplemented in a subclass to receive widget resize events which are passe...
Definition qwidget.cpp:9822
QCursor cursor
the cursor shape for this widget
Definition qwidget.h:135
QScreen * screen() const
Returns the screen the widget is on.
Definition qwidget.cpp:2496
void setForegroundRole(QPalette::ColorRole)
Sets the foreground role of the widget to role.
Definition qwidget.cpp:4456
QPointF mapFromGlobal(const QPointF &) const
Translates the global screen coordinate pos to widget coordinates.
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition qwidget.h:910
\inmodule QtGui
Definition qwindow.h:63
#define this
Definition dialogs.cpp:9
QOpenGLWidget * widget
[1]
QString text
rect
[4]
QStyleOptionButton opt
T fromNativePixels(const T &value, const C *context)
Combined button and popup list for selecting options.
Definition qcompare.h:63
@ AlignLeft
Definition qnamespace.h:144
@ WA_StyleSheet
Definition qnamespace.h:372
Q_GUI_EXPORT bool mightBeRichText(QAnyStringView)
Returns true if the string text is likely to be rich text; otherwise returns false.
@ UI_AnimateTooltip
@ UI_FadeTooltip
@ Key_ScrollLock
Definition qnamespace.h:689
#define Q_UNLIKELY(x)
#define qApp
void qScrollEffect(QWidget *w, QEffects::DirFlags orient, int time)
Definition qeffects.cpp:525
void qFadeEffect(QWidget *w, int time)
Definition qeffects.cpp:547
#define Q_GLOBAL_STATIC(TYPE, NAME,...)
#define qWarning
Definition qlogging.h:166
constexpr const T & qMax(const T &a, const T &b)
Definition qminmax.h:42
GLuint64 key
GLfloat GLfloat GLfloat w
[0]
GLboolean r
[2]
GLenum GLuint GLintptr offset
GLfloat GLfloat p
[1]
GLuint GLenum option
QStyleSheetStyle * qt_styleSheet(QStyle *style)
#define Q_OBJECT
#define slots
#define Q_UNUSED(x)
ptrdiff_t qsizetype
Definition qtypes.h:165
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)
QObject::connect nullptr
myObject disconnect()
[26]
args<< 1<< 2;QJSValue threeAgain=fun.call(args);QString fileName="helloworld.qs";QFile scriptFile(fileName);if(!scriptFile.open(QIODevice::ReadOnly)) QTextStream stream(&scriptFile);QString contents=stream.readAll();scriptFile.close();myEngine.evaluate(contents, fileName);myEngine.globalObject().setProperty("myNumber", 123);...QJSValue myNumberPlusOne=myEngine.evaluate("myNumber + 1");QJSValue result=myEngine.evaluate(...);if(result.isError()) qDebug()<< "Uncaught exception at line"<< result.property("lineNumber").toInt()<< ":"<< result.toString();QPushButton *button=new QPushButton;QJSValue scriptButton=myEngine.newQObject(button);myEngine.globalObject().setProperty("button", scriptButton);myEngine.evaluate("button.checkable = true");qDebug()<< scriptButton.property("checkable").toBool();scriptButton.property("show").call();QJSEngine engine;QObject *myQObject=new QObject();myQObject- setProperty)("dynamicProperty", 3)