34 #include <QBackingStore>
35 #include <QPaintDevice>
37 #include <QRandomGenerator>
38 #include <QResizeEvent>
55 void CoordinateControl::setCoordinates(
int x,
int y)
70 void CoordinateControl::spinBoxChanged()
72 const int x = m_x->
value();
73 const int y = m_y->
value();
87 l->addWidget(m_point);
105 void RectControl::handleChanged()
115 , m_moveEventLabel(new
QLabel(
tr(
"Move events")))
116 , m_resizeEventLabel(new
QLabel(
tr(
"Resize events")))
117 , m_mouseEventLabel(new
QLabel(
tr(
"Mouse events")))
137 l->addWidget(m_moveEventLabel);
138 l->addWidget(m_resizeEventLabel);
139 l->addWidget(m_mouseEventLabel);
152 m_resizeEventLabel->
setText(
tr(
"Resize %1x%2 (#%3)")
154 .arg(++m_resizeCount));
160 m_moveEventLabel->
setText(
tr(
"Move %1,%2 (#%3)")
161 .arg(me->
pos().
x()).arg(me->
pos().
y())
162 .arg(++m_moveCount));
170 m_mouseEventLabel->
setText(
tr(
"Mouse: %1,%2 Global: %3,%4 ").
171 arg(
pos.
x()).arg(
pos.
y()).arg(globalPos.
x()).arg(globalPos.
y()));
182 void BaseWindowControl::posChanged(
const QPoint &
p)
189 void BaseWindowControl::sizeChanged(
const QSize &
s)
196 void BaseWindowControl::framePosChanged(
const QPoint &
p)
217 void statesChanged();
230 virtual Qt::WindowFlags objectWindowFlags(
const QObject *
o)
const
232 virtual void setObjectWindowFlags(
QObject *
o, Qt::WindowFlags
f);
246 void WidgetWindowControl::setObjectWindowFlags(
QObject *
o, Qt::WindowFlags
f)
249 const bool visible =
w->isVisible();
250 w->setWindowFlags(
f);
263 void WidgetWindowControl::statesChanged()
267 w->setWindowState(m_statesControl->
states());
294 QPoint m_mouseDownPosition;
300 if (m_mouseDownPosition.
isNull())
303 QPoint delta = ev->
pos() - m_mouseDownPosition;
305 setPosition(newPosition);
311 m_mouseDownPosition = ev->
pos();
316 m_mouseDownPosition =
QPoint();
319 void Window::render()
327 p.fillRect(
rect, m_color);
349 void toggleAttachWindow();
350 void addChildWindow();
357 {
return static_cast<const QWindow *
>(
o)->framePosition(); }
359 {
static_cast<QWindow *
>(
o)->setFramePosition(
p); }
362 virtual void setObjectWindowFlags(
QObject *
o, Qt::WindowFlags
f)
363 {
static_cast<QWindow *
>(
o)->setFlags(
f); }
374 , m_detachedParent(0)
408 void WindowControl::showWindow()
413 void WindowControl::hideWindow()
418 void WindowControl::raiseWindow()
423 void WindowControl::lowerWindow()
428 void WindowControl::toggleAttachWindow()
430 if (m_detachedParent) {
432 m_window->setParent(m_detachedParent);
434 m_detachedParent = 0;
436 m_detachedParent = m_window->parent();
438 m_window->setParent(0);
443 void WindowControl::addChildWindow()
445 qDebug() <<
"WindowControl::addChildWindow";
448 QRect childGeometry(50, 50, 40, 40);
456 , m_testWindow(new
Window)
474 if (offsetArgIndex >=0 && offsetArgIndex <
args.size() - 1)
475 y +=
args.at(offsetArgIndex + 1).toInt();
485 m_testWindow->setFramePosition(
QPoint(
x,
y));
486 m_testWindow->resize(200, 200);
493 "<html><head/><body><p>This example lets you control the geometry"
494 " of QWindows and child QWindows");
496 l->addWidget(
new QLabel(labelText));
499 l->addWidget(windowControl);
510 #include "controllerwidget.moc"
virtual bool eventFilter(QObject *, QEvent *)
BaseWindowControl(QObject *w)
CoordinateControl(const QString &sep)
void sizeValueChanged(const QSize &s)
void pointValueChanged(const QPoint &p)
QPoint pointValue() const
void setPointValue(const QPoint &p)
void setSizeValue(const QSize &s)
The QAction class provides an abstraction for user commands that can be added to different user inter...
The QBackingStore class provides a drawing area for QWindow.
QPaintDevice * paintDevice()
void beginPaint(const QRegion &)
void flush(const QRegion ®ion, QWindow *window=nullptr, const QPoint &offset=QPoint())
void resize(const QSize &size)
void addWidget(QWidget *, int stretch=0, Qt::Alignment alignment=Qt::Alignment())
void setSpacing(int spacing) override
static QStringList arguments()
The QEvent class is the base class of all event classes. Event objects contain event parameters.
The QExposeEvent class contains event parameters for expose events. \inmodule QtGui.
QGraphicsObject * parent
the parent of the item
The QGridLayout class lays out widgets in a grid.
void addWidget(QWidget *w)
The QGroupBox widget provides a group box frame with a title.
QGroupBox(QWidget *parent=nullptr)
void clicked(bool checked=false)
void setTitle(const QString &title)
The QHBoxLayout class lines up widgets horizontally.
The QKeySequence class encapsulates a key sequence as used by shortcuts.
The QLabel widget provides a text or image display.
void setText(const QString &)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal.
The QMainWindow class provides a main application window.\inmodule QtWidgets.
void setCentralWidget(QWidget *widget)
The QMouseEvent class contains parameters that describe a mouse event.
The QMoveEvent class contains event parameters for move events. \inmodule QtGui.
const QPoint & pos() const
The QObject class is the base class of all Qt objects.
void installEventFilter(QObject *filterObj)
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
bool blockSignals(bool b) noexcept
void setObjectName(const QString &name)
bool setProperty(const char *name, const QVariant &value)
The QPainter class performs low-level painting on widgets and other paint devices.
The QPoint class defines a point in the plane using integer precision.
constexpr bool isNull() const noexcept
constexpr int x() const noexcept
constexpr int y() const noexcept
The QRandomGenerator class allows one to obtain random values from a high-quality Random Number Gener...
The QRect class defines a rectangle in the plane using integer precision.
constexpr void moveTopLeft(const QPoint &p) noexcept
constexpr int height() const noexcept
constexpr void setSize(const QSize &s) noexcept
constexpr QSize size() const noexcept
constexpr int width() const noexcept
The QResizeEvent class contains event parameters for resize events. \inmodule QtGui.
const QSize & size() const
T * data() const noexcept
The QSize class defines the size of a two-dimensional object using integer point precision.
constexpr int height() const noexcept
constexpr int width() const noexcept
constexpr bool isEmpty() const noexcept
The QSpacerItem class provides blank space in a layout.
The QSpinBox class provides a spin box widget.
int value
the value of the spin box
The QString class provides a Unicode character string.
The QStringList class provides a list of strings.
The QVBoxLayout class lines up widgets vertically.
The QVariant class acts like a union for the most common Qt data types.
The QWindow class represents a window in the underlying windowing system.
void setTitle(const QString &)
void changed(const QRect &r)
void setRectValue(const QRect &r)
void positionChanged(const QPoint &s)
void sizeChanged(const QSize &s)
WindowControl(QWindow *w)
[Window class definition]
void mousePressEvent(QMouseEvent *ev)
void mouseMoveEvent(QMouseEvent *ev)
void mousePressEvent(QMouseEvent *) override
void mouseReleaseEvent(QMouseEvent *e)
void mouseMoveEvent(QMouseEvent *) override
Window(QWindow *parent=nullptr)
void mouseReleaseEvent(QMouseEvent *) override
void exposeEvent(QExposeEvent *)
Qt::WindowStates states() const
void setVisibleValue(bool)
bool visibleValue() const
void setStates(Qt::WindowStates s)
QHighDpiScaling::Point position(T, QHighDpiScaling::Point::Kind)
@ WindowFullscreenButtonHint
@ WindowMaximizeButtonHint
@ WindowMinimizeButtonHint
std::pair< T1, T2 > QPair
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLenum GLenum GLsizei void * row
#define QStringLiteral(str)
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent