30 #include <QtWidgets/qgraphicsanchorlayout.h>
31 #include <QtWidgets/qgraphicslinearlayout.h>
32 #include <QtWidgets/qgraphicswidget.h>
33 #include <QtWidgets/qgraphicsview.h>
43 void hard_complex_data();
45 void linearVsAnchorSizeHints_data();
46 void linearVsAnchorSizeHints();
47 void linearVsAnchorSetGeometry_data();
48 void linearVsAnchorSetGeometry();
49 void linearVsAnchorNested_data();
50 void linearVsAnchorNested();
76 w->setPreferredSize(preferred);
77 w->setMaximumSize(maximum);
89 QGraphicsAnchor *anchor =
l->addAnchor(firstItem, firstEdge, secondItem, secondEdge);
93 void tst_QGraphicsAnchorLayout::hard_complex_data()
95 QTest::addColumn<int>(
"whichSizeHint");
107 void tst_QGraphicsAnchorLayout::hard_complex()
109 QFETCH(
int, whichSizeHint);
126 l->setContentsMargins(0, 0, 0, 0);
160 l->setMinimumSize(60,40);
161 l->setPreferredSize(220,40);
162 l->setMaximumSize(240,40);
164 switch (whichSizeHint) {
166 l->setMinimumSize(-1, -1);
169 l->setPreferredSize(-1, -1);
172 l->setMaximumSize(-1, -1);
181 sizeHint =
l->effectiveSizeHint((
Qt::SizeHint)whichSizeHint);
185 sizeHint =
l->effectiveSizeHint((
Qt::SizeHint)whichSizeHint);
201 if (whichLayout == 0) {
232 void tst_QGraphicsAnchorLayout::linearVsAnchorSizeHints_data()
234 QTest::addColumn<int>(
"whichLayout");
235 QTest::addColumn<int>(
"whichSizeHint");
256 void tst_QGraphicsAnchorLayout::linearVsAnchorSizeHints()
258 QFETCH(
int, whichSizeHint);
266 sizeHint =
l->effectiveSizeHint((
Qt::SizeHint)whichSizeHint);
271 sizeHint =
l->effectiveSizeHint((
Qt::SizeHint)whichSizeHint);
275 void tst_QGraphicsAnchorLayout::linearVsAnchorSetGeometry_data()
277 QTest::addColumn<int>(
"whichLayout");
285 void tst_QGraphicsAnchorLayout::linearVsAnchorSetGeometry()
299 l->setGeometry(sizeHint);
306 l->setGeometry(sizeHint);
311 void tst_QGraphicsAnchorLayout::linearVsAnchorNested_data()
313 QTest::addColumn<int>(
"whichLayout");
322 void tst_QGraphicsAnchorLayout::linearVsAnchorNested()
337 if (whichLayout == 0) {
350 }
else if (whichLayout == 1) {
420 #include "tst_qgraphicsanchorlayout.moc"
void invalidate() override
The QGraphicsAnchor class represents an anchor between two items in a QGraphicsAnchorLayout.
void setSpacing(qreal spacing)
The QGraphicsAnchorLayout class provides a layout where one can anchor widgets together in Graphics V...
QGraphicsAnchor * addAnchor(QGraphicsLayoutItem *firstItem, Qt::AnchorPoint firstEdge, QGraphicsLayoutItem *secondItem, Qt::AnchorPoint secondEdge)
void addCornerAnchors(QGraphicsLayoutItem *firstItem, Qt::Corner firstCorner, QGraphicsLayoutItem *secondItem, Qt::Corner secondCorner)
void addAnchors(QGraphicsLayoutItem *firstItem, QGraphicsLayoutItem *secondItem, Qt::Orientations orientations=Qt::Horizontal|Qt::Vertical)
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
The QGraphicsLayout class provides the base class for all layouts in Graphics View.
void setContentsMargins(qreal left, qreal top, qreal right, qreal bottom)
The QGraphicsLayoutItem class can be inherited to allow your custom items to be managed by layouts.
void setMinimumSize(const QSizeF &size)
The QGraphicsLinearLayout class provides a horizontal or vertical layout for managing widgets in Grap...
void addItem(QGraphicsLayoutItem *item)
QGraphicsObject * parent
the parent of the item
The QObject class is the base class of all Qt objects.
The QPainter class performs low-level painting on widgets and other paint devices.
void drawLine(const QLineF &line)
void drawRoundedRect(const QRectF &rect, qreal xRadius, qreal yRadius, Qt::SizeMode mode=Qt::AbsoluteSize)
The QRectF class defines a finite rectangle in the plane using floating point precision.
constexpr qreal width() const noexcept
constexpr void setWidth(qreal w) noexcept
constexpr void setSize(const QSizeF &s) noexcept
The QSizeF class defines the size of a two-dimensional object using floating point precision.
The QSize class defines the size of a two-dimensional object using integer point precision.
The QString class provides a Unicode character string.
The QStyleOptionGraphicsItem class is used to describe the parameters needed to draw a QGraphicsItem.
~tst_QGraphicsAnchorLayout()
tst_QGraphicsAnchorLayout()
Q_TESTLIB_EXPORT QTestData & newRow(const char *dataTag)
QT_END_INCLUDE_NAMESPACE typedef double qreal
GLboolean GLboolean GLboolean b
GLfloat GLfloat GLfloat w
[0]
GLboolean GLboolean GLboolean GLboolean a
[7]
#define QTEST_MAIN(TestObject)
#define QFETCH(Type, name)
QtConcurrent::task([]{ qDebug("Hello, world!");}).spawn(FutureResult void increment(QPromise< int > &promise, int i)
[10]