Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
grid_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4//
5// W A R N I N G
6// -------------
7//
8// This file is not part of the Qt API. It exists for the convenience
9// of Qt Designer. This header
10// file may change from version to version without notice, or even be removed.
11//
12// We mean it.
13//
14
15#ifndef QDESIGNER_GRID_H
16#define QDESIGNER_GRID_H
17
19
20#include <QtCore/qcompare.h>
21#include <QtCore/qvariant.h>
22
24
25class QWidget;
26class QPaintEvent;
27class QPainter;
28
29namespace qdesigner_internal {
30
31// Designer grid which is able to serialize to QVariantMap
33{
34public:
35 Grid();
36
37 bool fromVariantMap(const QVariantMap& vm);
38
39 void addToVariantMap(QVariantMap& vm, bool forceKeys = false) const;
40 QVariantMap toVariantMap(bool forceKeys = false) const;
41
42 inline bool visible() const { return m_visible; }
44
45 inline bool snapX() const { return m_snapX; }
46 void setSnapX(bool snap) { m_snapX = snap; }
47
48 inline bool snapY() const { return m_snapY; }
49 void setSnapY(bool snap) { m_snapY = snap; }
50
51 inline int deltaX() const { return m_deltaX; }
52 void setDeltaX(int dx) { m_deltaX = dx; }
53
54 inline int deltaY() const { return m_deltaY; }
55 void setDeltaY(int dy) { m_deltaY = dy; }
56
57 void paint(QWidget *widget, QPaintEvent *e) const;
58 void paint(QPainter &p, const QWidget *widget, QPaintEvent *e) const;
59
60 QPoint snapPoint(const QPoint &p) const;
61
62 int widgetHandleAdjustX(int x) const;
63 int widgetHandleAdjustY(int y) const;
64
65private:
66 friend bool comparesEqual(const Grid &lhs, const Grid &rhs) noexcept
67 {
68 return lhs.m_visible == rhs.m_visible
71 }
73
74 int snapValue(int value, int grid) const;
75 bool m_visible;
76 bool m_snapX;
77 bool m_snapY;
78 int m_deltaX;
79 int m_deltaY;
80};
81} // namespace qdesigner_internal
82
83QT_END_NAMESPACE
84
85#endif // QDESIGNER_GRID_H
friend class QPainter
friend class QWidget
Definition qpainter.h:421
FormEditorOptionsPage(QDesignerFormEditorInterface *core)
void fromSettings(const QDesignerSharedSettings &s)
void toSettings(QDesignerSharedSettings &s) const
Combined button and popup list for selecting options.
Auxiliary methods to store/retrieve settings.
#define QDESIGNER_SHARED_EXPORT