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
qquickapplication.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 <QtQuick/private/qquickapplication_p.h>
5
6#include <QtGui/private/qguiapplication_p.h>
7#include <QtGui/qpa/qplatformintegration.h>
8#include <QtGui/qguiapplication.h>
9
10#include <QtQml/private/qqmlglobal_p.h>
11
12#include <QtCore/private/qobject_p.h>
13#include <QtCore/qdebug.h>
14
16
23
140/* The following properties are from QQmlApplication.
141 ### Document those in QQmlApplication instead once it is exposed
142*/
143
215 : QQmlApplication(parent)
216{
218 if (QGuiApplication *guiApp = qobject_cast<QGuiApplication *>(app)) {
227
228 connect(guiApp, &QGuiApplication::primaryScreenChanged, this, &QQuickApplication::updateScreens);
229 connect(guiApp, &QGuiApplication::screenAdded, this, &QQuickApplication::updateScreens);
230 connect(guiApp, &QGuiApplication::screenRemoved, this, &QQuickApplication::updateScreens);
231 updateScreens();
232 }
233}
234
238
243
248
253
258
263
268
270{
272}
273
278
279qsizetype screens_count(QQmlListProperty<QQuickScreenInfo> *prop)
280{
281 return static_cast<QVector<QQuickScreenInfo *> *>(prop->data)->size();
282}
283
284QQuickScreenInfo *screens_at(QQmlListProperty<QQuickScreenInfo> *prop, qsizetype idx)
285{
286 return static_cast<QVector<QQuickScreenInfo *> *>(prop->data)->at(idx);
287}
288
289QQmlListProperty<QQuickScreenInfo> QQuickApplication::screens()
290{
291 return QQmlListProperty<QQuickScreenInfo>(this,
292 const_cast<QVector<QQuickScreenInfo *> *>(&m_screens), &screens_count, &screens_at);
293}
294
295void QQuickApplication::updateScreens()
296{
297 const QList<QScreen *> screenList = QGuiApplication::screens();
298 m_screens.resize(screenList.size());
299 for (int i = 0; i < screenList.size(); ++i) {
300 if (!m_screens[i])
301 m_screens[i] = new QQuickScreenInfo(this);
302 m_screens[i]->setWrappedScreen(screenList[i]);
303 }
305}
306
308
309#include "moc_qquickapplication_p.cpp"
\inmodule QtCore
static QCoreApplication * instance() noexcept
Returns a pointer to the application's QCoreApplication (or QGuiApplication/QApplication) instance.
\reentrant
Definition qfont.h:22
static QPlatformIntegration * platformIntegration()
\macro qGuiApp
void primaryScreenChanged(QScreen *screen)
static Qt::ApplicationState applicationState()
void applicationStateChanged(Qt::ApplicationState state)
static QFont font()
Returns the default application font.
static QStyleHints * styleHints()
Returns the application's style hints.
void screenRemoved(QScreen *screen)
This signal is emitted whenever a screen is removed from the system.
static void setApplicationDisplayName(const QString &name)
void applicationDisplayNameChanged()
QString applicationDisplayName
the user-visible name of this application
void layoutDirectionChanged(Qt::LayoutDirection direction)
Qt::LayoutDirection layoutDirection
the default layout direction for this application
void screenAdded(QScreen *screen)
This signal is emitted whenever a new screen screen has been added to the system.
static QList< QScreen * > screens()
Returns a list of all the screens associated with the windowing system the application is connected t...
\inmodule QtCore
Definition qobject.h:103
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
Qt::LayoutDirection layoutDirection
Qt::ApplicationState state
void setDisplayName(const QString &displayName)
QQuickApplication(QObject *parent=nullptr)
\qmlproperty bool Application::active
QQmlListProperty< QQuickScreenInfo > screens
void displayNameChanged()
void stateChanged(Qt::ApplicationState state)
void layoutDirectionChanged()
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
The QStyleHints class contains platform specific hints and settings. \inmodule QtGui.
Definition qstylehints.h:17
Combined button and popup list for selecting options.
LayoutDirection
ApplicationState
Definition qnamespace.h:262
@ ApplicationActive
Definition qnamespace.h:266
static QString displayName(CGDirectDisplayID displayID)
GLenum GLuint GLintptr GLsizeiptr size
[1]
qsizetype screens_count(QQmlListProperty< QQuickScreenInfo > *prop)
QQuickScreenInfo * screens_at(QQmlListProperty< QQuickScreenInfo > *prop, qsizetype idx)
#define emit
ptrdiff_t qsizetype
Definition qtypes.h:165
QApplication app(argc, argv)
[0]
QAction * at