pytest-qt icon indicating copy to clipboard operation
pytest-qt copied to clipboard

QtGuiTest methods exposed in Qt 6.9

Open The-Compiler opened this issue 1 year ago • 0 comments

Qt 6.9 will expose various QtGuiTest methods used by e.g. Squish that could be useful for us too: QtGuiTest namespace: Export symbols (610419) · Gerrit Code Review

namespace QtGuiTest
{
    Q_NAMESPACE_EXPORT(Q_GUI_EXPORT)

    Q_GUI_EXPORT void setKeyboardModifiers(Qt::KeyboardModifiers modifiers);
    Q_GUI_EXPORT void setCursorPosition(const QPoint &position);
    Q_GUI_EXPORT void synthesizeExtendedKeyEvent(QEvent::Type type, int key, Qt::KeyboardModifiers modifiers,
                                    quint32 nativeScanCode, quint32 nativeVirtualKey,
                                    const QString &text);
    Q_GUI_EXPORT bool synthesizeKeyEvent(QWindow *window, QEvent::Type t, int k, Qt::KeyboardModifiers mods,
                            const QString & text = QString(), bool autorep = false,
                            ushort count = 1);

    Q_GUI_EXPORT void synthesizeMouseEvent(const QPointF &position, Qt::MouseButtons state,
                              Qt::MouseButton button, QEvent::Type type,
                              Qt::KeyboardModifiers modifiers);

    Q_GUI_EXPORT void synthesizeWheelEvent(int rollCount, Qt::KeyboardModifiers modifiers);

    Q_GUI_EXPORT qint64 eventTimeElapsed();

    Q_GUI_EXPORT void postFakeWindowActivation(QWindow *window);

    Q_GUI_EXPORT QPoint toNativePixels(const QPoint &value, const QWindow *window);
    Q_GUI_EXPORT QRect toNativePixels(const QRect &value, const QWindow *window);
    Q_GUI_EXPORT qreal factor(const QWindow *window);

    Q_GUI_EXPORT void setEventPointId(QEventPoint &p, int arg);
    Q_GUI_EXPORT void setEventPointPressure(QEventPoint &p, qreal arg);
    Q_GUI_EXPORT void setEventPointState(QEventPoint &p, QEventPoint::State arg);
    Q_GUI_EXPORT void setEventPointPosition(QEventPoint &p, QPointF arg);
    Q_GUI_EXPORT void setEventPointGlobalPosition(QEventPoint &p, QPointF arg);
    Q_GUI_EXPORT void setEventPointScenePosition(QEventPoint &p, QPointF arg);
    Q_GUI_EXPORT void setEventPointEllipseDiameters(QEventPoint &p, QSizeF arg);
} // namespace QtGuiTest

Obviously not something actionable right now, but something we should keep in mind once Qt 6.9 is out (scheduled for March 2025). Hopefully PyQt/PySide will expose them too.

Corresponding docs: https://github.com/qt/qtbase/blob/2bdce97480ed66f0e8e9528fbc8f4f9c3d8487bf/src/gui/kernel/qtestsupport_gui.cpp#L203-L499

The-Compiler avatar Dec 10 '24 15:12 The-Compiler