void tst_QFormLayout::spacing()
{
    //TODO: confirm spacing behavior
    QWidget *w = new QWidget;
    CustomLayoutStyle *style = new CustomLayoutStyle;
    style->hspacing = 5;
    style->vspacing = 10;
    w->setStyle(style);
    QFormLayout *fl = new QFormLayout(w);
    QCOMPARE(style->hspacing, fl->horizontalSpacing());
    QCOMPARE(style->vspacing, fl->verticalSpacing());

    //QCOMPARE(fl->spacing(), -1);
    fl->setVerticalSpacing(5);
    QCOMPARE(5, fl->horizontalSpacing());
    QCOMPARE(5, fl->verticalSpacing());
    //QCOMPARE(fl->spacing(), 5);
    fl->setVerticalSpacing(-1);
    QCOMPARE(style->hspacing, fl->horizontalSpacing());
    QCOMPARE(style->vspacing, fl->verticalSpacing());

    style->hspacing = 5;
    style->vspacing = 5;
    //QCOMPARE(fl->spacing(), 5);

    fl->setHorizontalSpacing(20);
    //QCOMPARE(fl->spacing(), -1);
    style->vspacing = 20;
    QCOMPARE(fl->horizontalSpacing(), 20);
    QCOMPARE(fl->verticalSpacing(), 20);
    //QCOMPARE(fl->spacing(), 20);
    fl->setHorizontalSpacing(-1);
    //QCOMPARE(fl->spacing(), -1);
    style->hspacing = 20;
    //QCOMPARE(fl->spacing(), 20);



    // Do not assert if spacings are negative (QTBUG-34731)
    style->vspacing = -1;
    style->hspacing = -1;
    QLabel *label = new QLabel(tr("Asserts"));
    QCheckBox *checkBox = new QCheckBox(tr("Yes"));
    fl->setWidget(0, QFormLayout::LabelRole, label);
    fl->setWidget(1, QFormLayout::FieldRole, checkBox);
    w->resize(200, 100);
    w->show();
    QVERIFY(QTest::qWaitForWindowExposed(w));

    delete w;
    delete style;
}
Beispiel #2
0
void tst_QFormLayout::spacing()
{
    //TODO: confirm spacing behavior
    QWidget *w = new QWidget;
    CustomLayoutStyle *style = new CustomLayoutStyle;
    style->hspacing = 5;
    style->vspacing = 10;
    w->setStyle(style);
    QFormLayout *fl = new QFormLayout(w);
    QCOMPARE(style->hspacing, fl->horizontalSpacing());
    QCOMPARE(style->vspacing, fl->verticalSpacing());

    //QCOMPARE(fl->spacing(), -1);
    fl->setVerticalSpacing(5);
    QCOMPARE(5, fl->horizontalSpacing());
    QCOMPARE(5, fl->verticalSpacing());
    //QCOMPARE(fl->spacing(), 5);
    fl->setVerticalSpacing(-1);
    QCOMPARE(style->hspacing, fl->horizontalSpacing());
    QCOMPARE(style->vspacing, fl->verticalSpacing());

    style->hspacing = 5;
    style->vspacing = 5;
    //QCOMPARE(fl->spacing(), 5);


    fl->setHorizontalSpacing(20);
    //QCOMPARE(fl->spacing(), -1);
    style->vspacing = 20;
    QCOMPARE(fl->horizontalSpacing(), 20);
    QCOMPARE(fl->verticalSpacing(), 20);
    //QCOMPARE(fl->spacing(), 20);
    fl->setHorizontalSpacing(-1);
    //QCOMPARE(fl->spacing(), -1);
    style->hspacing = 20;
    //QCOMPARE(fl->spacing(), 20);

    delete w;
    delete style;
}