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
qtesthelpers_p.h
Go to the documentation of this file.
1// Copyright (C) 2017 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#ifndef QTESTHELPERS_P_H
5#define QTESTHELPERS_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/QFile>
19#include <QtCore/QString>
20#include <QtCore/QChar>
21#include <QtCore/QPoint>
22#include <QtCore/private/qglobal_p.h>
23
24#ifdef QT_GUI_LIB
25#include <QtGui/QGuiApplication>
26#include <QtGui/QScreen>
27#endif
28
29#ifdef QT_WIDGETS_LIB
30#include <QtWidgets/QWidget>
31#endif
32
34
35namespace QTestPrivate {
36
37static inline bool canHandleUnicodeFileNames()
38{
39#if defined(Q_OS_WIN)
40 return true;
41#else
42 // Check for UTF-8 by converting the Euro symbol (see tst_utf8)
43 return QFile::encodeName(QString(QChar(0x20AC))) == QByteArrayLiteral("\342\202\254");
44#endif
45}
46
47#ifdef QT_WIDGETS_LIB
48static inline void centerOnScreen(QWidget *w, const QSize &size)
49{
50 const QPoint offset = QPoint(size.width() / 2, size.height() / 2);
51 w->move(QGuiApplication::primaryScreen()->availableGeometry().center() - offset);
52}
53
54static inline void centerOnScreen(QWidget *w)
55{
56 centerOnScreen(w, w->geometry().size());
57}
58
63static inline void setFrameless(QWidget *w)
64{
65 Qt::WindowFlags flags = w->windowFlags();
69 w->setWindowFlags(flags);
70}
71
72static inline void androidCompatibleShow(QWidget *widget)
73{
74 // On Android QWidget::show() shows the widget maximized, so if we need
75 // to move or resize the widget, we need to explicitly call
76 // QWidget::setVisible(true) instead, because that's what show() actually
77 // does on desktop platforms.
78#ifdef Q_OS_ANDROID
79 widget->setVisible(true);
80#else
81 widget->show();
82#endif
83}
84#endif // QT_WIDGETS_LIB
85
86} // namespace QTestPrivate
87
89
90#endif // QTESTHELPERS_P_H
\inmodule QtCore
static QByteArray encodeName(const QString &fileName)
Converts fileName to an 8-bit encoding that you can use in native APIs.
Definition qfile.h:158
QScreen * primaryScreen
the primary (or default) screen of the application.
\inmodule QtCore\reentrant
Definition qpoint.h:25
\inmodule QtCore
Definition qsize.h:25
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
void show()
Shows the widget and its child widgets.
Definition qwidget.cpp:7875
virtual void setVisible(bool visible)
Definition qwidget.cpp:8255
QOpenGLWidget * widget
[1]
void centerOnScreen(QQuickView *window, const QSize &size)
Combined button and popup list for selecting options.
static bool canHandleUnicodeFileNames()
@ FramelessWindowHint
Definition qnamespace.h:225
@ WindowMinMaxButtonsHint
Definition qnamespace.h:230
@ WindowTitleHint
Definition qnamespace.h:226
@ WindowSystemMenuHint
Definition qnamespace.h:227
@ WindowCloseButtonHint
Definition qnamespace.h:241
#define QByteArrayLiteral(str)
Definition qbytearray.h:52
GLfloat GLfloat GLfloat w
[0]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLbitfield flags
GLenum GLuint GLintptr offset