mirror of
https://github.com/crystalidea/qt6windows7.git
synced 2025-07-02 15:26:00 +08:00
qt 6.5.1 original
This commit is contained in:
19
tests/manual/qlayout/CMakeLists.txt
Normal file
19
tests/manual/qlayout/CMakeLists.txt
Normal file
@ -0,0 +1,19 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## qlayout Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_manual_test(qlayout
|
||||
GUI
|
||||
SOURCES
|
||||
gridwidget.cpp gridwidget.h
|
||||
hbwidget.cpp hbwidget.h
|
||||
main.cpp
|
||||
mainwindow.cpp mainwindow.h
|
||||
vbwidget.cpp vbwidget.h
|
||||
LIBRARIES
|
||||
Qt::Gui
|
||||
Qt::Widgets
|
||||
)
|
44
tests/manual/qlayout/gridwidget.cpp
Normal file
44
tests/manual/qlayout/gridwidget.cpp
Normal file
@ -0,0 +1,44 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "gridwidget.h"
|
||||
#include <QGridLayout>
|
||||
#include <QPushButton>
|
||||
#include <QComboBox>
|
||||
#include <QDateTimeEdit>
|
||||
#include <QLineEdit>
|
||||
#include <QSpinBox>
|
||||
#include <QLabel>
|
||||
#include <QCheckBox>
|
||||
|
||||
GridWidget::GridWidget(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
{
|
||||
QGridLayout *hb = new QGridLayout(this);
|
||||
hb->setObjectName("GridWidget");
|
||||
QComboBox *combo = new QComboBox();
|
||||
combo->addItem("123");
|
||||
QComboBox *combo2 = new QComboBox();
|
||||
combo2->setEditable(true);
|
||||
combo2->addItem("123");
|
||||
|
||||
hb->addWidget(new QLabel("123"), 0, 0);
|
||||
hb->addWidget(new QLabel("123"), 0, 1);
|
||||
hb->addWidget(new QLineEdit("123"), 1, 0);
|
||||
hb->addWidget(new QLineEdit("123"), 1, 1);
|
||||
hb->addWidget(new QCheckBox("123"), 0, 2);
|
||||
hb->addWidget(new QCheckBox("123"), 1, 2);
|
||||
hb->addWidget(combo, 0, 3);
|
||||
hb->addWidget(combo2, 1, 3);
|
||||
hb->addWidget(new QDateTimeEdit(), 0, 4);
|
||||
hb->addWidget(new QPushButton("123"), 1, 4);
|
||||
hb->addWidget(new QSpinBox(), 0, 5);
|
||||
hb->addWidget(new QSpinBox(), 1, 5);
|
||||
|
||||
qDebug("There should be four warnings, but no crash or freeze:");
|
||||
hb->addWidget(this, 6, 6); ///< This command should print a warning, but should not add "this"
|
||||
hb->addWidget(nullptr, 6, 7); ///< This command should print a warning, but should not add "NULL"
|
||||
hb->addLayout(hb, 7, 6); ///< This command should print a warning, but should not add "hb"
|
||||
hb->addLayout(nullptr, 7, 7); ///< This command should print a warning, but should not add "NULL"
|
||||
qDebug("Neither crashed nor frozen");
|
||||
}
|
21
tests/manual/qlayout/gridwidget.h
Normal file
21
tests/manual/qlayout/gridwidget.h
Normal file
@ -0,0 +1,21 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#ifndef GRIDWIDGET_H
|
||||
#define GRIDWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class GridWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit GridWidget(QWidget *parent = nullptr);
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
};
|
||||
|
||||
#endif // GRIDWIDGET_H
|
40
tests/manual/qlayout/hbwidget.cpp
Normal file
40
tests/manual/qlayout/hbwidget.cpp
Normal file
@ -0,0 +1,40 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "hbwidget.h"
|
||||
#include <QHBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QComboBox>
|
||||
#include <QDateTimeEdit>
|
||||
#include <QLineEdit>
|
||||
#include <QSpinBox>
|
||||
#include <QLabel>
|
||||
#include <QCheckBox>
|
||||
|
||||
HbWidget::HbWidget(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
{
|
||||
QHBoxLayout *hb = new QHBoxLayout(this);
|
||||
hb->setObjectName("HbWidget");
|
||||
QComboBox *combo = new QComboBox(this);
|
||||
combo->addItem("123");
|
||||
QComboBox *combo2 = new QComboBox();
|
||||
combo2->setEditable(true);
|
||||
combo2->addItem("123");
|
||||
|
||||
hb->addWidget(new QLabel("123"));
|
||||
hb->addWidget(new QLineEdit("123"));
|
||||
hb->addWidget(combo);
|
||||
hb->addWidget(combo2);
|
||||
hb->addWidget(new QCheckBox("123"));
|
||||
hb->addWidget(new QDateTimeEdit());
|
||||
hb->addWidget(new QPushButton("123"));
|
||||
hb->addWidget(new QSpinBox());
|
||||
|
||||
qDebug("There should be four warnings, but no crash or freeze:");
|
||||
hb->addWidget(this); ///< This command should print a warning, but should not add "this"
|
||||
hb->addWidget(nullptr); ///< This command should print a warning, but should not add "NULL"
|
||||
hb->addLayout(hb); ///< This command should print a warning, but should not add "hb"
|
||||
hb->addLayout(nullptr); ///< This command should print a warning, but should not add "NULL"
|
||||
qDebug("Neither crashed nor frozen");
|
||||
}
|
21
tests/manual/qlayout/hbwidget.h
Normal file
21
tests/manual/qlayout/hbwidget.h
Normal file
@ -0,0 +1,21 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#ifndef HBWIDGET_H
|
||||
#define HBWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class HbWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit HbWidget(QWidget *parent = nullptr);
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
};
|
||||
|
||||
#endif // HBWIDGET_H
|
14
tests/manual/qlayout/main.cpp
Normal file
14
tests/manual/qlayout/main.cpp
Normal file
@ -0,0 +1,14 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include <QApplication>
|
||||
#include "mainwindow.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
w.show();
|
||||
|
||||
return a.exec();
|
||||
}
|
55
tests/manual/qlayout/mainwindow.cpp
Normal file
55
tests/manual/qlayout/mainwindow.cpp
Normal file
@ -0,0 +1,55 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "hbwidget.h"
|
||||
#include "vbwidget.h"
|
||||
#include "gridwidget.h"
|
||||
#include <QGridLayout>
|
||||
#include <QComboBox>
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
{
|
||||
QWidget *widget = new QWidget(this);
|
||||
setCentralWidget(widget);
|
||||
m_mainLayout = new QGridLayout(widget);
|
||||
|
||||
QComboBox *combo = new QComboBox();
|
||||
combo->addItem("HBox Layout");
|
||||
combo->addItem("VBox Layout");
|
||||
combo->addItem("Grid Layout");
|
||||
connect(combo, SIGNAL(currentIndexChanged(int)), this, SLOT(layoutIndexChanged(int)));
|
||||
HbWidget *hbWidget = new HbWidget(this);
|
||||
|
||||
m_mainLayout->addWidget(combo);
|
||||
m_mainLayout->addWidget(hbWidget);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::layoutIndexChanged(int index)
|
||||
{
|
||||
delete m_mainLayout->takeAt(1)->widget();
|
||||
|
||||
switch (index) {
|
||||
case 0: {
|
||||
HbWidget *hbWidget = new HbWidget(this);
|
||||
m_mainLayout->addWidget(hbWidget);
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
VbWidget *vbWidget = new VbWidget(this);
|
||||
m_mainLayout->addWidget(vbWidget);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
GridWidget *gridW = new GridWidget(this);
|
||||
m_mainLayout->addWidget(gridW);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
26
tests/manual/qlayout/mainwindow.h
Normal file
26
tests/manual/qlayout/mainwindow.h
Normal file
@ -0,0 +1,26 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
class QGridLayout;
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
|
||||
private slots:
|
||||
void layoutIndexChanged(int index);
|
||||
|
||||
private:
|
||||
QGridLayout *m_mainLayout;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
14
tests/manual/qlayout/qlayout.pro
Normal file
14
tests/manual/qlayout/qlayout.pro
Normal file
@ -0,0 +1,14 @@
|
||||
QT += widgets
|
||||
|
||||
TEMPLATE = app
|
||||
|
||||
SOURCES += main.cpp\
|
||||
mainwindow.cpp \
|
||||
hbwidget.cpp \
|
||||
gridwidget.cpp \
|
||||
vbwidget.cpp
|
||||
|
||||
HEADERS += mainwindow.h \
|
||||
hbwidget.h \
|
||||
gridwidget.h \
|
||||
vbwidget.h
|
40
tests/manual/qlayout/vbwidget.cpp
Normal file
40
tests/manual/qlayout/vbwidget.cpp
Normal file
@ -0,0 +1,40 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "vbwidget.h"
|
||||
#include <QVBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QComboBox>
|
||||
#include <QDateTimeEdit>
|
||||
#include <QLineEdit>
|
||||
#include <QSpinBox>
|
||||
#include <QLabel>
|
||||
#include <QCheckBox>
|
||||
|
||||
VbWidget::VbWidget(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
{
|
||||
QVBoxLayout *hb = new QVBoxLayout(this);
|
||||
hb->setObjectName("VbWidget");
|
||||
QComboBox *combo = new QComboBox(this);
|
||||
combo->addItem("123");
|
||||
QComboBox *combo2 = new QComboBox();
|
||||
combo2->setEditable(true);
|
||||
combo2->addItem("123");
|
||||
|
||||
hb->addWidget(new QLabel("123"));
|
||||
hb->addWidget(new QLineEdit("123"));
|
||||
hb->addWidget(combo);
|
||||
hb->addWidget(combo2);
|
||||
hb->addWidget(new QCheckBox("123"));
|
||||
hb->addWidget(new QDateTimeEdit());
|
||||
hb->addWidget(new QPushButton("123"));
|
||||
hb->addWidget(new QSpinBox());
|
||||
|
||||
qDebug("There should be four warnings, but no crash or freeze:");
|
||||
hb->addWidget(this); ///< This command should print a warning, but should not add "this"
|
||||
hb->addWidget(nullptr); ///< This command should print a warning, but should not add "NULL"
|
||||
hb->addLayout(hb); ///< This command should print a warning, but should not add "hb"
|
||||
hb->addLayout(nullptr); ///< This command should print a warning, but should not add "NULL"
|
||||
qDebug("Neither crashed nor frozen");
|
||||
}
|
21
tests/manual/qlayout/vbwidget.h
Normal file
21
tests/manual/qlayout/vbwidget.h
Normal file
@ -0,0 +1,21 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#ifndef VBWIDGET_H
|
||||
#define VBWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class VbWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit VbWidget(QWidget *parent = nullptr);
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
};
|
||||
|
||||
#endif // VBWIDGET_H
|
Reference in New Issue
Block a user