mirror of
https://github.com/crystalidea/qt6windows7.git
synced 2025-07-04 16:25:27 +08:00
qt 6.5.1 original
This commit is contained in:
8
tests/manual/widgets/CMakeLists.txt
Normal file
8
tests/manual/widgets/CMakeLists.txt
Normal file
@ -0,0 +1,8 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
add_subdirectory(itemviews)
|
||||
add_subdirectory(qgraphicsview)
|
||||
add_subdirectory(kernel)
|
||||
add_subdirectory(widgets)
|
||||
add_subdirectory(styles)
|
9
tests/manual/widgets/itemviews/CMakeLists.txt
Normal file
9
tests/manual/widgets/itemviews/CMakeLists.txt
Normal file
@ -0,0 +1,9 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
add_subdirectory(delegate)
|
||||
add_subdirectory(qconcatenatetablesproxymodel)
|
||||
add_subdirectory(qheaderview)
|
||||
add_subdirectory(qtreeview)
|
||||
add_subdirectory(qtreewidget)
|
||||
add_subdirectory(tableview-span-navigation)
|
@ -0,0 +1,15 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## testtable1 Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_manual_test(testtable1
|
||||
GUI
|
||||
SOURCES
|
||||
testtable1.cpp
|
||||
LIBRARIES
|
||||
Qt::Gui
|
||||
Qt::Widgets
|
||||
)
|
@ -0,0 +1,78 @@
|
||||
// Copyright (C) 2012 Thorbjørn Lund Martsum - tmartsum[at]gmail.com
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include <QtWidgets/QtWidgets>
|
||||
|
||||
const int rowCount = 2000;
|
||||
|
||||
class TableDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TableDialog() : model(rowCount, 3) { create(); }
|
||||
void create()
|
||||
{
|
||||
resize(1000, 233);
|
||||
gridLayout = new QGridLayout(this);
|
||||
tableView = new QTableView(this);
|
||||
|
||||
gridLayout->addWidget(tableView, 0, 0, 2, 1);
|
||||
spinPrecision = new QSpinBox(this);
|
||||
gridLayout->addWidget(spinPrecision, 0, 1, 1, 1);
|
||||
verticalSpacer = new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
||||
gridLayout->addItem(verticalSpacer, 1, 1, 1, 1);
|
||||
|
||||
QString ii = QString::fromLatin1("ii");
|
||||
QStringList is;
|
||||
spinPrecision->setMinimum(-1);
|
||||
spinPrecision->setMaximum(rowCount + 2);
|
||||
for (int u = 0; u < rowCount; ++u) {
|
||||
if (u % 25 == 0)
|
||||
ii += QString::fromLatin1("i");
|
||||
else
|
||||
ii[ii.length() - 1] = QChar::fromLatin1('a' + (u % 25));
|
||||
ii[ii.length() - 2] = QChar::fromLatin1('i');
|
||||
is.append(ii);
|
||||
}
|
||||
|
||||
for (int u = 0; u < rowCount; ++u) {
|
||||
QString col1;
|
||||
col1 = QString::fromLatin1("Row: %1").arg(u);
|
||||
model.setData(model.index(u, 0), col1);
|
||||
model.setData(model.index(u, 1), is[u]);
|
||||
model.setData(model.index(u, 2), is[rowCount - u -1]);
|
||||
}
|
||||
tableView->setModel(&model);
|
||||
|
||||
tableView->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
|
||||
tableView->horizontalHeader()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
|
||||
tableView->horizontalHeader()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
|
||||
spinPrecision->setValue(tableView->horizontalHeader()->resizeContentsPrecision());
|
||||
connect(spinPrecision, SIGNAL(valueChanged(int)), this, SLOT(slotValueChanged(int)));
|
||||
} // setupUi
|
||||
protected slots:
|
||||
void slotValueChanged(int newval);
|
||||
protected:
|
||||
QGridLayout *gridLayout;
|
||||
QTableView *tableView;
|
||||
QSpinBox *spinPrecision;
|
||||
QSpacerItem *verticalSpacer;
|
||||
QStandardItemModel model;
|
||||
};
|
||||
|
||||
void TableDialog::slotValueChanged(int newval)
|
||||
{
|
||||
tableView->horizontalHeader()->setResizeContentsPrecision(newval);
|
||||
tableView->resizeColumnsToContents();
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
TableDialog d1;
|
||||
d1.show();
|
||||
app.exec();
|
||||
}
|
||||
|
||||
#include "testtable1.moc"
|
@ -0,0 +1,2 @@
|
||||
SOURCES = testtable1.cpp
|
||||
QT += widgets
|
@ -0,0 +1,15 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## testtable2 Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_manual_test(testtable2
|
||||
GUI
|
||||
SOURCES
|
||||
testtable2.cpp
|
||||
LIBRARIES
|
||||
Qt::Gui
|
||||
Qt::Widgets
|
||||
)
|
@ -0,0 +1,88 @@
|
||||
// Copyright (C) 2012 Thorbjørn Lund Martsum - tmartsum[at]gmail.com
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include <QtWidgets/QtWidgets>
|
||||
|
||||
const int columnCount = 1500;
|
||||
|
||||
class TableDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TableDialog() : model(2, columnCount) { create(); }
|
||||
void create()
|
||||
{
|
||||
resize(1200, 400);
|
||||
gridLayout = new QGridLayout(this);
|
||||
tableView = new QTableView(this);
|
||||
|
||||
gridLayout->addWidget(tableView, 0, 0, 2, 1);
|
||||
spinPrecision = new QSpinBox(this);
|
||||
gridLayout->addWidget(spinPrecision, 0, 1, 1, 1);
|
||||
verticalSpacer = new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
||||
gridLayout->addItem(verticalSpacer, 1, 1, 1, 1);
|
||||
|
||||
QString ii = QString::fromLatin1("ii");
|
||||
QStringList is;
|
||||
spinPrecision->setMinimum(-1);
|
||||
spinPrecision->setMaximum(columnCount + 2);
|
||||
|
||||
QFont f = QApplication::font();
|
||||
for (int u = 0; u < columnCount; ++u) {
|
||||
int size = 10 + (u % 63);
|
||||
f.setPixelSize(size);
|
||||
QString col;
|
||||
if (u % 50 < 25)
|
||||
col = QChar::fromLatin1('a' + (u % 25));
|
||||
else
|
||||
col = QChar::fromLatin1('A' + (u % 25));
|
||||
|
||||
int v = columnCount - u - 1;
|
||||
model.setData(model.index(0, u), col);
|
||||
model.setData(model.index(1, v), col);
|
||||
|
||||
model.setData(model.index(0, u), f, Qt::FontRole);
|
||||
model.setData(model.index(1, v), f, Qt::FontRole);
|
||||
}
|
||||
tableView->setModel(&model);
|
||||
|
||||
for (int u = 0; u < columnCount; ++ u)
|
||||
tableView->horizontalHeader()->resizeSection(u, 60);
|
||||
|
||||
// Make last index in first row a bit special
|
||||
f.setPixelSize(96);
|
||||
model.setData(model.index(0, columnCount - 1), f, Qt::FontRole);
|
||||
model.setData(model.index(0, columnCount - 1), QString::fromLatin1("qI"));
|
||||
tableView->horizontalHeader()->resizeSection(columnCount - 1, 140);
|
||||
|
||||
tableView->verticalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
|
||||
tableView->verticalHeader()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
|
||||
spinPrecision->setValue(tableView->verticalHeader()->resizeContentsPrecision());
|
||||
connect(spinPrecision, SIGNAL(valueChanged(int)), this, SLOT(slotValueChanged(int)));
|
||||
} // setupUi
|
||||
protected slots:
|
||||
void slotValueChanged(int newval);
|
||||
protected:
|
||||
QGridLayout *gridLayout;
|
||||
QTableView *tableView;
|
||||
QSpinBox *spinPrecision;
|
||||
QSpacerItem *verticalSpacer;
|
||||
QStandardItemModel model;
|
||||
};
|
||||
|
||||
void TableDialog::slotValueChanged(int newval)
|
||||
{
|
||||
tableView->verticalHeader()->setResizeContentsPrecision(newval);
|
||||
tableView->resizeRowsToContents();
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
TableDialog d1;
|
||||
d1.show();
|
||||
app.exec();
|
||||
}
|
||||
|
||||
#include "testtable2.moc"
|
@ -0,0 +1,2 @@
|
||||
SOURCES = testtable2.cpp
|
||||
QT += widgets
|
@ -0,0 +1,15 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## testtree Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_manual_test(testtree
|
||||
GUI
|
||||
SOURCES
|
||||
testtree.cpp
|
||||
LIBRARIES
|
||||
Qt::Gui
|
||||
Qt::Widgets
|
||||
)
|
@ -0,0 +1,96 @@
|
||||
// Copyright (C) 2012 Thorbjørn Lund Martsum - tmartsum[at]gmail.com
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include <QtWidgets/QtWidgets>
|
||||
|
||||
class TreeDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TreeDialog() { create(); }
|
||||
protected:
|
||||
void create()
|
||||
{
|
||||
resize(1000, 233);
|
||||
gridLayout = new QGridLayout(this);
|
||||
treeWidget = new QTreeWidget(this);
|
||||
|
||||
gridLayout->addWidget(treeWidget, 0, 0, 2, 1);
|
||||
spinPrecision = new QSpinBox(this);
|
||||
gridLayout->addWidget(spinPrecision, 0, 1, 1, 1);
|
||||
verticalSpacer = new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
||||
gridLayout->addItem(verticalSpacer, 1, 1, 1, 1);
|
||||
|
||||
QStringList itemInfo("Col1");
|
||||
itemInfo.append("Col2");
|
||||
itemInfo.append("Col3");
|
||||
itemInfo.append("Dummy");
|
||||
// Developer no. could also have been social security number og some other id.
|
||||
treeWidget->setHeaderLabels(itemInfo);
|
||||
|
||||
QStringList sl1("This is Root Item");
|
||||
sl1.append("i");
|
||||
QTreeWidgetItem *rootitem = new QTreeWidgetItem(treeWidget, sl1);
|
||||
|
||||
QStringList sl2("This is Child1 Item");
|
||||
sl2.append("WW");
|
||||
QTreeWidgetItem *child1 = new QTreeWidgetItem(rootitem, sl2);
|
||||
|
||||
QString ii = QString::fromLatin1("ii");
|
||||
QStringList is;
|
||||
const int rowCount = 3000;
|
||||
spinPrecision->setMinimum(-1);
|
||||
spinPrecision->setMaximum(rowCount + 5);
|
||||
for (int u = 0; u < rowCount; ++u) {
|
||||
if (u % 25 == 0)
|
||||
ii += QString::fromLatin1("i");
|
||||
else
|
||||
ii[ii.length() - 1] = QChar::fromLatin1('a' + (u % 25));
|
||||
ii[ii.length() - 2] = QChar::fromLatin1('i');
|
||||
is.append(ii);
|
||||
}
|
||||
|
||||
for (int u = 0; u < rowCount - 2; ++u) { // -2 since we have rootitem and child1
|
||||
QString col1;
|
||||
col1 = QString::fromLatin1("This is child item %1").arg(u + 2);
|
||||
|
||||
QStringList sl(col1);
|
||||
sl.append(is[u]);
|
||||
sl.append(is[rowCount - u - 1]);
|
||||
|
||||
if (u > 500)
|
||||
new QTreeWidgetItem(rootitem, sl);
|
||||
else
|
||||
new QTreeWidgetItem(child1, sl);
|
||||
}
|
||||
treeWidget->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
|
||||
treeWidget->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
|
||||
treeWidget->header()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
|
||||
spinPrecision->setValue(treeWidget->header()->resizeContentsPrecision());
|
||||
connect(spinPrecision, SIGNAL(valueChanged(int)), this, SLOT(slotValueChanged(int)));
|
||||
} // setupUi
|
||||
protected slots:
|
||||
void slotValueChanged(int newval);
|
||||
protected:
|
||||
QGridLayout *gridLayout;
|
||||
QTreeWidget *treeWidget;
|
||||
QSpinBox *spinPrecision;
|
||||
QSpacerItem *verticalSpacer;
|
||||
};
|
||||
|
||||
void TreeDialog::slotValueChanged(int newval)
|
||||
{
|
||||
treeWidget->header()->setResizeContentsPrecision(newval);
|
||||
for (int u = 0; u < treeWidget->header()->count(); ++u)
|
||||
treeWidget->resizeColumnToContents(u);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
TreeDialog d1;
|
||||
d1.show();
|
||||
app.exec();
|
||||
}
|
||||
|
||||
#include "testtree.moc"
|
@ -0,0 +1,2 @@
|
||||
SOURCES = testtree.cpp
|
||||
QT += widgets
|
15
tests/manual/widgets/itemviews/delegate/CMakeLists.txt
Normal file
15
tests/manual/widgets/itemviews/delegate/CMakeLists.txt
Normal file
@ -0,0 +1,15 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## delegate Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_manual_test(delegate
|
||||
GUI
|
||||
SOURCES
|
||||
example.cpp
|
||||
LIBRARIES
|
||||
Qt::Gui
|
||||
Qt::Widgets
|
||||
)
|
3
tests/manual/widgets/itemviews/delegate/delegate.pro
Normal file
3
tests/manual/widgets/itemviews/delegate/delegate.pro
Normal file
@ -0,0 +1,3 @@
|
||||
TEMPLATE = app
|
||||
QT += widgets
|
||||
SOURCES=example.cpp
|
82
tests/manual/widgets/itemviews/delegate/example.cpp
Normal file
82
tests/manual/widgets/itemviews/delegate/example.cpp
Normal file
@ -0,0 +1,82 @@
|
||||
// Copyright (C) 2012 Thorbjørn Lund Martsum - tmartsum[at]gmail.com
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include <QLineEdit>
|
||||
#include <QApplication>
|
||||
#include <QTableView>
|
||||
#include <QStandardItemModel>
|
||||
#include <QItemDelegate>
|
||||
#include <QDebug>
|
||||
#include <QComboBox>
|
||||
|
||||
class ExampleEditor : public QLineEdit
|
||||
{
|
||||
public:
|
||||
ExampleEditor(QWidget *parent = nullptr):QLineEdit(parent) { qDebug() << "ctor"; }
|
||||
~ExampleEditor() { QApplication::instance()->quit(); }
|
||||
};
|
||||
|
||||
class ExampleDelegate : public QItemDelegate
|
||||
{
|
||||
public:
|
||||
ExampleDelegate() : QItemDelegate()
|
||||
{
|
||||
m_editor = new ExampleEditor(0);
|
||||
m_combobox = new QComboBox(0);
|
||||
m_combobox->addItem(QString::fromUtf8("item1"));
|
||||
m_combobox->addItem(QString::fromUtf8("item2"));
|
||||
}
|
||||
protected:
|
||||
QWidget* createEditor(QWidget *p, const QStyleOptionViewItem &o, const QModelIndex &i) const
|
||||
{
|
||||
// doubleclick rownumber 3 (last row) to see the difference.
|
||||
if (i.row() == 3) {
|
||||
m_combobox->setParent(p);
|
||||
m_combobox->setGeometry(o.rect);
|
||||
return m_combobox;
|
||||
} else {
|
||||
m_editor->setParent(p);
|
||||
m_editor->setGeometry(o.rect);
|
||||
return m_editor;
|
||||
}
|
||||
}
|
||||
void destroyEditor(QWidget *editor, const QModelIndex &) const
|
||||
{
|
||||
editor->setParent(0);
|
||||
qDebug() << "intercepted destroy :)";
|
||||
}
|
||||
|
||||
// Avoid setting data - and therefore show that the editor keeps its state.
|
||||
void setEditorData(QWidget* w, const QModelIndex &) const
|
||||
{
|
||||
QComboBox *combobox = qobject_cast<QComboBox*>(w);
|
||||
if (combobox) {
|
||||
qDebug() << "Try to show popup at once";
|
||||
// Now we could try to make a call to
|
||||
// QCoreApplication::processEvents();
|
||||
// But it does not matter. The fix:
|
||||
// https://codereview.qt-project.org/40608
|
||||
// is blocking QComboBox from reacting to this doubleclick edit event
|
||||
// and we need to do that since the mouseReleaseEvent has not yet happened,
|
||||
// and therefore cannot be processed.
|
||||
combobox->showPopup();
|
||||
}
|
||||
}
|
||||
|
||||
~ExampleDelegate() { delete m_editor; }
|
||||
mutable ExampleEditor *m_editor;
|
||||
mutable QComboBox *m_combobox;
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
QTableView tv;
|
||||
QStandardItemModel m;
|
||||
m.setRowCount(4);
|
||||
m.setColumnCount(2);
|
||||
tv.setModel(&m);
|
||||
tv.show();
|
||||
tv.setItemDelegate(new ExampleDelegate());
|
||||
app.exec();
|
||||
}
|
8
tests/manual/widgets/itemviews/itemviews.pro
Normal file
8
tests/manual/widgets/itemviews/itemviews.pro
Normal file
@ -0,0 +1,8 @@
|
||||
TEMPLATE = subdirs
|
||||
SUBDIRS = delegate \
|
||||
qconcatenatetablesproxymodel \
|
||||
qheaderview \
|
||||
qtreeview \
|
||||
qtreewidget \
|
||||
tableview-span-navigation \
|
||||
|
@ -0,0 +1,17 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## qconcatenatetablesproxymodel Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_manual_test(qconcatenatetablesproxymodel
|
||||
GUI
|
||||
SOURCES
|
||||
main.cpp
|
||||
INCLUDE_DIRECTORIES
|
||||
.
|
||||
LIBRARIES
|
||||
Qt::Gui
|
||||
Qt::Widgets
|
||||
)
|
@ -0,0 +1,63 @@
|
||||
// Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author David Faure <david.faure@kdab.com>
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include <QApplication>
|
||||
#include <QConcatenateTablesProxyModel>
|
||||
#include <QStandardItemModel>
|
||||
#include <QTableView>
|
||||
#include <QTreeView>
|
||||
|
||||
static void prepareModel(const QString &prefix, QStandardItemModel *model)
|
||||
{
|
||||
for (int row = 0; row < model->rowCount(); ++row) {
|
||||
for (int column = 0; column < model->columnCount(); ++column) {
|
||||
QStandardItem *item = new QStandardItem(prefix + QString(" %1,%2").arg(row).arg(column));
|
||||
item->setDragEnabled(true);
|
||||
item->setDropEnabled(true);
|
||||
model->setItem(row, column, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
QStandardItemModel firstModel(4, 4);
|
||||
prepareModel("First", &firstModel);
|
||||
QStandardItemModel secondModel(2, 2);
|
||||
|
||||
QConcatenateTablesProxyModel proxy;
|
||||
proxy.addSourceModel(&firstModel);
|
||||
proxy.addSourceModel(&secondModel);
|
||||
|
||||
prepareModel("Second", &secondModel);
|
||||
|
||||
QTableView tableView;
|
||||
tableView.setWindowTitle("concat proxy, in QTableView");
|
||||
tableView.setDragDropMode(QAbstractItemView::DragDrop);
|
||||
tableView.setModel(&proxy);
|
||||
tableView.show();
|
||||
|
||||
QTreeView treeView;
|
||||
treeView.setWindowTitle("concat proxy, in QTreeView");
|
||||
treeView.setDragDropMode(QAbstractItemView::DragDrop);
|
||||
treeView.setModel(&proxy);
|
||||
treeView.show();
|
||||
|
||||
// For comparison, views on top on QStandardItemModel
|
||||
|
||||
QTableView tableViewTest;
|
||||
tableViewTest.setWindowTitle("first model, in QTableView");
|
||||
tableViewTest.setDragDropMode(QAbstractItemView::DragDrop);
|
||||
tableViewTest.setModel(&firstModel);
|
||||
tableViewTest.show();
|
||||
|
||||
QTreeView treeViewTest;
|
||||
treeViewTest.setWindowTitle("first model, in QTreeView");
|
||||
treeViewTest.setDragDropMode(QAbstractItemView::DragDrop);
|
||||
treeViewTest.setModel(&firstModel);
|
||||
treeViewTest.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
|
||||
TEMPLATE = app
|
||||
TARGET = qconcatenatetablesproxymodel
|
||||
INCLUDEPATH += .
|
||||
|
||||
QT += widgets
|
||||
|
||||
SOURCES += main.cpp
|
15
tests/manual/widgets/itemviews/qheaderview/CMakeLists.txt
Normal file
15
tests/manual/widgets/itemviews/qheaderview/CMakeLists.txt
Normal file
@ -0,0 +1,15 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## qheaderview Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_manual_test(qheaderview
|
||||
GUI
|
||||
SOURCES
|
||||
qheaderviewtest1.cpp
|
||||
LIBRARIES
|
||||
Qt::Gui
|
||||
Qt::Widgets
|
||||
)
|
@ -0,0 +1,3 @@
|
||||
TEMPLATE = app
|
||||
SOURCES = qheaderviewtest1.cpp
|
||||
QT += widgets
|
217
tests/manual/widgets/itemviews/qheaderview/qheaderviewtest1.cpp
Normal file
217
tests/manual/widgets/itemviews/qheaderview/qheaderviewtest1.cpp
Normal file
@ -0,0 +1,217 @@
|
||||
// Copyright (C) 2012 Thorbjørn Lund Martsum - tmartsum[at]gmail.com
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include <QtWidgets/QtWidgets>
|
||||
|
||||
struct ManualTask {
|
||||
const char *title;
|
||||
const char *instructions;
|
||||
unsigned sectionsMovable : 1;
|
||||
unsigned selectionMode : 3;
|
||||
};
|
||||
|
||||
ManualTask tasks[] = {
|
||||
{ QT_TR_NOOP("0. Default"),
|
||||
"Please provide instructions",
|
||||
true, QAbstractItemView::SingleSelection
|
||||
},
|
||||
{ QT_TR_NOOP("1. Autoscroll"),
|
||||
"<ol>"
|
||||
"<li>Press and hold on section 9 of vertical header.<br/>"
|
||||
"<em>(all cells in the row will be selected)</em>"
|
||||
"</li>"
|
||||
"<li>Extend the selection by moving the mouse down.<br/>"
|
||||
"<em>(selection will extend to the next rows)</em>"
|
||||
"</li>"
|
||||
"<li>Continue to move the mouse down and outside the window geometry.<br/>"
|
||||
"<em>(The view should scroll automatically and the selection should still extend)</em>"
|
||||
"</li>"
|
||||
"<li>While still holding the button, do the same in the opposite direction, i.e. move mouse up and outside the window geometry.<br/>"
|
||||
"<em>(Verify that the view scrolls automatically and the selection changes)</em>"
|
||||
"</li>"
|
||||
"<li>Verify that it works in the other dimension, i.e Press and hold section 9 of the horizontal header.<br/>"
|
||||
"<em>All cells in the column will be selected</em>"
|
||||
"</li>"
|
||||
"<li>Extend the selection by moving the mouse to the far right and outside the window geometry.<br/>"
|
||||
"<em>(selection will extend to the next columns)</em>"
|
||||
"</li>"
|
||||
"<li>Verify that it works in the opposite direction (i.e. move mouse to the left of the window geometry).<br/>"
|
||||
"<em>(Verify that the view scrolls automatically and the selection changes)</em>"
|
||||
"</li>"
|
||||
"</ol>",
|
||||
false, QAbstractItemView::ExtendedSelection
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
class Window : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Window(QWidget *parent = nullptr): QWidget(parent), ckMovable(0), tableView(0), cbSelectionMode(0), m_taskInstructions(0)
|
||||
{
|
||||
m_taskInstructions = new QLabel();
|
||||
if (sizeof(tasks) > 0)
|
||||
m_taskInstructions->setText(tr(tasks[0].instructions));
|
||||
|
||||
QVBoxLayout *vbox = new QVBoxLayout(this);
|
||||
vbox->addLayout(setupComboBox());
|
||||
vbox->addWidget(setupGroupBox());
|
||||
vbox->addWidget(setupTableView());
|
||||
vbox->addWidget(m_taskInstructions);
|
||||
}
|
||||
|
||||
void updateControls()
|
||||
{
|
||||
ckMovable->setChecked(tableView->verticalHeader()->sectionsMovable());
|
||||
QAbstractItemView::SelectionMode sMode = tableView->selectionMode();
|
||||
cbSelectionMode->setCurrentIndex((int)sMode);
|
||||
}
|
||||
|
||||
private:
|
||||
QFormLayout *setupComboBox()
|
||||
{
|
||||
QComboBox *combo = new QComboBox;
|
||||
for (size_t i = 0; i < sizeof(tasks) / sizeof(tasks[0]); ++i) {
|
||||
combo->addItem(tr(tasks[i].title));
|
||||
}
|
||||
|
||||
connect(combo, SIGNAL(currentIndexChanged(int)), this, SLOT(on_taskCombo_currentIndexChanged(int)));
|
||||
QFormLayout *form = new QFormLayout;
|
||||
form->addRow(tr("Choose task:"), combo);
|
||||
return form;
|
||||
}
|
||||
|
||||
QGroupBox *setupGroupBox()
|
||||
{
|
||||
QGroupBox *grp = new QGroupBox(tr("Properties"));
|
||||
QFormLayout *form = new QFormLayout;
|
||||
grp->setLayout(form);
|
||||
ckMovable = new QCheckBox;
|
||||
ckMovable->setObjectName(QLatin1String("ckMovable"));
|
||||
connect(ckMovable, SIGNAL(toggled(bool)), this, SLOT(on_ckMovable_toggled(bool)));
|
||||
form->addRow(tr("SectionsMovable"), ckMovable);
|
||||
|
||||
cbSelectionMode = new QComboBox;
|
||||
cbSelectionMode->setObjectName(QLatin1String("cbSelectionMode"));
|
||||
cbSelectionMode->addItems(QStringList() << QLatin1String("NoSelection")
|
||||
<< QLatin1String("SingleSelection")
|
||||
<< QLatin1String("MultiSelection")
|
||||
<< QLatin1String("ExtendedSelection")
|
||||
<< QLatin1String("ContiguousSelection")
|
||||
);
|
||||
|
||||
connect(cbSelectionMode, SIGNAL(currentIndexChanged(int)), this, SLOT(on_cbSelectionMode_currentIndexChanged(int)));
|
||||
form->addRow(tr("SelectionMode"), cbSelectionMode);
|
||||
return grp;
|
||||
}
|
||||
|
||||
QTableView *setupTableView()
|
||||
{
|
||||
tableView = new QTableView;
|
||||
const int rowCount = 200;
|
||||
m.setRowCount(rowCount);
|
||||
m.setColumnCount(250);
|
||||
tableView->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
tableView->setModel(&m);
|
||||
tableView->verticalHeader()->swapSections(rowCount - 1, 5);
|
||||
return tableView;
|
||||
}
|
||||
|
||||
private Q_SLOTS:
|
||||
void on_ckMovable_toggled(bool arg)
|
||||
{
|
||||
tableView->verticalHeader()->setSectionsMovable(arg);
|
||||
tableView->horizontalHeader()->setSectionsMovable(arg);
|
||||
}
|
||||
|
||||
void on_cbSelectionMode_currentIndexChanged(int idx)
|
||||
{
|
||||
tableView->setSelectionMode((QAbstractItemView::SelectionMode)idx);
|
||||
}
|
||||
|
||||
void on_taskCombo_currentIndexChanged(int idx)
|
||||
{
|
||||
ManualTask &task = tasks[idx];
|
||||
m_taskInstructions->setText(tr(task.instructions));
|
||||
ckMovable->setChecked(task.sectionsMovable);
|
||||
cbSelectionMode->setCurrentIndex((QAbstractItemView::SelectionMode)task.selectionMode);
|
||||
}
|
||||
|
||||
public:
|
||||
QCheckBox *ckMovable;
|
||||
QTableView *tableView;
|
||||
QStandardItemModel m;
|
||||
QComboBox *cbSelectionMode;
|
||||
QLabel *m_taskInstructions;
|
||||
};
|
||||
|
||||
class SomeHandler : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
QHeaderView *m_hv;
|
||||
QTableView *m_tv;
|
||||
public:
|
||||
SomeHandler(QHeaderView *hv, QTableView *tv);
|
||||
public slots:
|
||||
void slotSectionResized(int, int, int);
|
||||
};
|
||||
|
||||
SomeHandler::SomeHandler(QHeaderView *hv, QTableView *tv)
|
||||
{
|
||||
m_hv = hv;
|
||||
m_tv = tv;
|
||||
m_tv->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||
connect(hv, SIGNAL(sectionResized(int,int,int)), this, SLOT(slotSectionResized(int,int,int)));
|
||||
}
|
||||
void SomeHandler::slotSectionResized(int logsection, int oldsize, int newsize)
|
||||
{
|
||||
int offset = m_hv->offset();
|
||||
m_tv->setUpdatesEnabled(false);
|
||||
// Do some manual resizing - lets make every section having the new size.
|
||||
m_hv->blockSignals(true);
|
||||
m_hv->setDefaultSectionSize(newsize);
|
||||
m_hv->blockSignals(false);
|
||||
|
||||
// Adjust offset and scrollbar. Maybe it isn't 100% perfect
|
||||
// but proof of concept
|
||||
// The test has sense without the define, too.
|
||||
#define DO_CORRECT_OFFSET_AND_SB
|
||||
#ifdef DO_CORRECT_OFFSET_AND_SB
|
||||
int leftRemoved = (m_hv->visualIndex(logsection)) * (oldsize - newsize);
|
||||
int newoffset = offset - leftRemoved;
|
||||
if (newoffset < 0)
|
||||
newoffset = 0;
|
||||
|
||||
if (newoffset > 0 && newoffset >= m_hv->count() * newsize - m_tv->viewport()->width())
|
||||
m_hv->setOffsetToLastSection();
|
||||
else
|
||||
m_hv->setOffset(newoffset);
|
||||
|
||||
m_tv->horizontalScrollBar()->blockSignals(true);
|
||||
m_tv->horizontalScrollBar()->setRange(0, m_hv->count() * newsize - m_tv->viewport()->width() );
|
||||
m_tv->horizontalScrollBar()->setValue(newoffset);
|
||||
m_tv->horizontalScrollBar()->blockSignals(false);
|
||||
#endif
|
||||
m_tv->setUpdatesEnabled(true);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
Window window;
|
||||
// Comment in the line below to test selection with keyboard (space)
|
||||
// tv.setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||
QHeaderView *hHeader = window.tableView->horizontalHeader();
|
||||
QHeaderView *vHeader = window.tableView->verticalHeader();
|
||||
SomeHandler handler(hHeader, window.tableView);
|
||||
hHeader->setDefaultSectionSize(30);
|
||||
window.resize(600, 600);
|
||||
window.show();
|
||||
hHeader->setSectionsMovable(true);
|
||||
vHeader->setSectionsMovable(true);
|
||||
window.updateControls();
|
||||
app.exec();
|
||||
}
|
||||
#include "qheaderviewtest1.moc"
|
15
tests/manual/widgets/itemviews/qtreeview/CMakeLists.txt
Normal file
15
tests/manual/widgets/itemviews/qtreeview/CMakeLists.txt
Normal file
@ -0,0 +1,15 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## qtreeview Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_manual_test(qtreeview
|
||||
GUI
|
||||
SOURCES
|
||||
main.cpp
|
||||
LIBRARIES
|
||||
Qt::Gui
|
||||
Qt::Widgets
|
||||
)
|
34
tests/manual/widgets/itemviews/qtreeview/main.cpp
Normal file
34
tests/manual/widgets/itemviews/qtreeview/main.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
// 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 <QtWidgets>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
QFileSystemModel model;
|
||||
QWidget window;
|
||||
QTreeView *tree = new QTreeView(&window);
|
||||
tree->setMaximumSize(1000, 600);
|
||||
|
||||
QHBoxLayout *layout = new QHBoxLayout;
|
||||
layout->setSizeConstraint(QLayout::SetFixedSize);
|
||||
layout->addWidget(tree);
|
||||
|
||||
window.setLayout(layout);
|
||||
model.setRootPath("");
|
||||
tree->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents);
|
||||
tree->setModel(&model);
|
||||
|
||||
tree->setAnimated(false);
|
||||
tree->setIndentation(20);
|
||||
tree->setSortingEnabled(true);
|
||||
tree->header()->setStretchLastSection(false);
|
||||
|
||||
window.setWindowTitle(QObject::tr("Dir View"));
|
||||
tree->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||
|
||||
window.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
3
tests/manual/widgets/itemviews/qtreeview/qtreeview.pro
Normal file
3
tests/manual/widgets/itemviews/qtreeview/qtreeview.pro
Normal file
@ -0,0 +1,3 @@
|
||||
TEMPLATE = app
|
||||
SOURCES = main.cpp
|
||||
QT += widgets
|
16
tests/manual/widgets/itemviews/qtreewidget/CMakeLists.txt
Normal file
16
tests/manual/widgets/itemviews/qtreewidget/CMakeLists.txt
Normal file
@ -0,0 +1,16 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## qtreewidget Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_manual_test(qtreewidget
|
||||
GUI
|
||||
SOURCES
|
||||
main.cpp
|
||||
LIBRARIES
|
||||
Qt::CorePrivate
|
||||
Qt::Gui
|
||||
Qt::Widgets
|
||||
)
|
128
tests/manual/widgets/itemviews/qtreewidget/main.cpp
Normal file
128
tests/manual/widgets/itemviews/qtreewidget/main.cpp
Normal file
@ -0,0 +1,128 @@
|
||||
// Copyright (C) 2012 Thorbjørn Lund Martsum - tmartsum[at]gmail.com
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QTreeWidget>
|
||||
#include <QGroupBox>
|
||||
#include <QRadioButton>
|
||||
#include <QDialog>
|
||||
#include <QApplication>
|
||||
#include <QHeaderView>
|
||||
|
||||
class ExampleDlg : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QVBoxLayout *groupLayout;
|
||||
QVBoxLayout *dialogLayout;
|
||||
QTreeWidget *treeWidget;
|
||||
QGroupBox *groupBox;
|
||||
QRadioButton *radioFirstName;
|
||||
QRadioButton *radioLastName;
|
||||
QRadioButton *radioDeveloperNo;
|
||||
QRadioButton *radioTitle;
|
||||
|
||||
ExampleDlg() : QDialog(0)
|
||||
{
|
||||
dialogLayout = new QVBoxLayout(this);
|
||||
treeWidget = new QTreeWidget(this);
|
||||
dialogLayout->addWidget(treeWidget);
|
||||
|
||||
groupBox = new QGroupBox(this);
|
||||
groupLayout = new QVBoxLayout(groupBox);
|
||||
radioFirstName = new QRadioButton("First Name", groupBox);
|
||||
groupLayout->addWidget(radioFirstName);
|
||||
radioLastName = new QRadioButton("Last Name", groupBox);
|
||||
groupLayout->addWidget(radioLastName);
|
||||
radioDeveloperNo = new QRadioButton("Developer No.", groupBox);
|
||||
groupLayout->addWidget(radioDeveloperNo);
|
||||
radioTitle = new QRadioButton("Title", groupBox);
|
||||
groupLayout->addWidget(radioTitle);
|
||||
dialogLayout->addWidget(groupBox);
|
||||
|
||||
QStringList item1sl("Barry");
|
||||
item1sl.append("Butter");
|
||||
item1sl.append("12199");
|
||||
item1sl.append("Key Maintainer");
|
||||
QTreeWidgetItem *item1 = new QTreeWidgetItem(treeWidget, item1sl);
|
||||
|
||||
QStringList item2sl("Cordon");
|
||||
item2sl.append("Rampsey");
|
||||
item2sl.append("59299");
|
||||
item2sl.append("Maintainer");
|
||||
QTreeWidgetItem *item2 = new QTreeWidgetItem(item1, item2sl);
|
||||
|
||||
QStringList item3sl("Samuel le");
|
||||
item3sl.append("Smackson");
|
||||
item3sl.append("708");
|
||||
item3sl.append("Contributer");
|
||||
/* QTreeWidgetItem *item3 = */ new QTreeWidgetItem(item2, item3sl);
|
||||
|
||||
QStringList item4sl("Georg");
|
||||
item4sl.append("Ambush");
|
||||
item4sl.append("86999");
|
||||
item4sl.append("Area Maintainer");
|
||||
QTreeWidgetItem *item4 = new QTreeWidgetItem(item1, item4sl);
|
||||
|
||||
QStringList item5sl("Arne");
|
||||
item5sl.append("Strassenleger");
|
||||
item5sl.append("338999");
|
||||
item5sl.append("Approver");
|
||||
/* QTreeWidgetItem *item4 =*/ new QTreeWidgetItem(item4, item5sl);
|
||||
|
||||
treeWidget->setDragEnabled(true);
|
||||
treeWidget->viewport()->setAcceptDrops(true);
|
||||
treeWidget->setDragDropMode(QAbstractItemView::InternalMove);
|
||||
|
||||
for (int u = 0; u < 12; ++u) {
|
||||
const QString username = QString("Anonymous User %1").arg(u + 1);
|
||||
QStringList info;
|
||||
info << username << username << QString::number(u + 1) << QStringLiteral("Test user");
|
||||
new QTreeWidgetItem(item4, info);
|
||||
}
|
||||
|
||||
treeWidget->expandAll();
|
||||
treeWidget->setColumnCount(item2sl.size());
|
||||
QStringList itemInfo("First Name");
|
||||
itemInfo.append("Last Name");
|
||||
itemInfo.append("Developer No.");
|
||||
// Developer no. could also have been social security number og some other id.
|
||||
itemInfo.append("Title");
|
||||
treeWidget->setHeaderLabels(itemInfo);
|
||||
radioLastName->setChecked(true);
|
||||
|
||||
connect(radioFirstName, SIGNAL(toggled(bool)), this, SLOT(fixDataInTree(bool)));
|
||||
connect(radioLastName, SIGNAL(toggled(bool)), this, SLOT(fixDataInTree(bool)));
|
||||
connect(radioDeveloperNo, SIGNAL(toggled(bool)), this, SLOT(fixDataInTree(bool)));
|
||||
connect(radioTitle, SIGNAL(toggled(bool)), this, SLOT(fixDataInTree(bool)));
|
||||
treeWidget->setTreePosition(-1);
|
||||
treeWidget->header()->swapSections(0, 1);
|
||||
}
|
||||
|
||||
protected slots:
|
||||
void fixDataInTree(bool checked)
|
||||
{
|
||||
if (!checked)
|
||||
return;
|
||||
int colInTree = 0; // first Name
|
||||
if (radioLastName->isChecked())
|
||||
colInTree = 1;
|
||||
if (radioDeveloperNo->isChecked())
|
||||
colInTree = 2;
|
||||
if (radioTitle->isChecked())
|
||||
colInTree = 3;
|
||||
treeWidget->header()->swapSections(0, treeWidget->header()->visualIndex(colInTree));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
ExampleDlg d;
|
||||
d.resize(d.sizeHint() * 3);
|
||||
d.show();
|
||||
app.exec();
|
||||
}
|
||||
|
||||
#include "main.moc"
|
@ -0,0 +1,3 @@
|
||||
TEMPLATE = app
|
||||
SOURCES = main.cpp
|
||||
QT += widgets core-private
|
@ -0,0 +1,17 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## tableview-span-navigation Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_manual_test(tableview-span-navigation
|
||||
GUI
|
||||
SOURCES
|
||||
main.cpp
|
||||
INCLUDE_DIRECTORIES
|
||||
.
|
||||
LIBRARIES
|
||||
Qt::Gui
|
||||
Qt::Widgets
|
||||
)
|
@ -0,0 +1,29 @@
|
||||
// Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include <QApplication>
|
||||
#include <QStandardItemModel>
|
||||
#include <QTableView>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
QStandardItemModel model(4, 4);
|
||||
QTableView tableView;
|
||||
tableView.setSizeAdjustPolicy(QTableView::AdjustToContents);
|
||||
tableView.setModel(&model);
|
||||
|
||||
for (int row = 0; row < model.rowCount(); ++row) {
|
||||
for (int column = 0; column < model.columnCount(); ++column) {
|
||||
QModelIndex index = model.index(row, column, QModelIndex());
|
||||
model.setData(index, QVariant(QString("%1,%2").arg(row).arg(column)));
|
||||
}
|
||||
}
|
||||
|
||||
tableView.setSpan(1, 1, 2, 2);
|
||||
|
||||
tableView.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
|
||||
TEMPLATE = app
|
||||
TARGET = tableview-span-navigation
|
||||
INCLUDEPATH += .
|
||||
|
||||
QT += widgets
|
||||
|
||||
SOURCES += main.cpp
|
7
tests/manual/widgets/kernel/CMakeLists.txt
Normal file
7
tests/manual/widgets/kernel/CMakeLists.txt
Normal file
@ -0,0 +1,7 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
# add_subdirectory(qtooltip) # special case broken in dev
|
||||
add_subdirectory(sizeonhide)
|
||||
add_subdirectory(layoutreplace)
|
||||
add_subdirectory(setscreen)
|
2
tests/manual/widgets/kernel/kernel.pro
Normal file
2
tests/manual/widgets/kernel/kernel.pro
Normal file
@ -0,0 +1,2 @@
|
||||
TEMPLATE = subdirs
|
||||
SUBDIRS = qtooltip sizeonhide layoutreplace setscreen
|
15
tests/manual/widgets/kernel/layoutreplace/CMakeLists.txt
Normal file
15
tests/manual/widgets/kernel/layoutreplace/CMakeLists.txt
Normal file
@ -0,0 +1,15 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## layoutreplace Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_manual_test(layoutreplace
|
||||
GUI
|
||||
SOURCES
|
||||
main.cpp
|
||||
LIBRARIES
|
||||
Qt::Gui
|
||||
Qt::Widgets
|
||||
)
|
@ -0,0 +1,2 @@
|
||||
SOURCES = main.cpp
|
||||
QT += widgets
|
99
tests/manual/widgets/kernel/layoutreplace/main.cpp
Normal file
99
tests/manual/widgets/kernel/layoutreplace/main.cpp
Normal file
@ -0,0 +1,99 @@
|
||||
// Copyright (C) 2013 Thorbjørn Martsum - tmartsum[at]gmail.com
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include <QGridLayout>
|
||||
#include <QFormLayout>
|
||||
#include <QStackedLayout>
|
||||
#include <QPushButton>
|
||||
#include <QLabel>
|
||||
#include <QApplication>
|
||||
|
||||
class ReplaceButton : public QPushButton
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ReplaceButton(const QString &text = QString("click to replace")) : QPushButton(text)
|
||||
{
|
||||
static int v = 0;
|
||||
++v;
|
||||
QString txt = QString("click to replace %1").arg(v);
|
||||
setText(txt);
|
||||
connect(this, SIGNAL(clicked()), this, SLOT(replace()));
|
||||
}
|
||||
protected slots:
|
||||
void replace()
|
||||
{
|
||||
if (!parentWidget())
|
||||
return;
|
||||
static int n = 0;
|
||||
++n;
|
||||
if (parentWidget()->layout()->replaceWidget(this, new QLabel(QString("replaced(%1)").arg(n))))
|
||||
deleteLater();
|
||||
}
|
||||
};
|
||||
|
||||
class StackButtonChange : public QPushButton
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
StackButtonChange(QStackedLayout *l) : QPushButton("stack wdg change")
|
||||
{
|
||||
sl = l;
|
||||
connect(this, SIGNAL(clicked()), this, SLOT(changeWdg()));
|
||||
}
|
||||
protected slots:
|
||||
void changeWdg()
|
||||
{
|
||||
int index = sl->indexOf(sl->currentWidget());
|
||||
++index;
|
||||
if (index >= sl->count())
|
||||
index = 0;
|
||||
sl->setCurrentWidget(sl->itemAt(index)->widget());
|
||||
sl->parentWidget()->update();
|
||||
}
|
||||
protected:
|
||||
QStackedLayout *sl;
|
||||
};
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
QApplication app(argc, argv);
|
||||
QWidget wdg1;
|
||||
QGridLayout *l1 = new QGridLayout();
|
||||
l1->addWidget(new ReplaceButton(), 1, 1, 2, 2, Qt::AlignCenter);
|
||||
l1->addWidget(new ReplaceButton(), 3, 1, 1, 1, Qt::AlignRight);
|
||||
l1->addWidget(new ReplaceButton(), 1, 3, 1, 1, Qt::AlignLeft);
|
||||
l1->addWidget(new ReplaceButton(), 2, 3, 1, 1, Qt::AlignLeft);
|
||||
l1->addWidget(new ReplaceButton(), 3, 2, 1, 1, Qt::AlignRight);
|
||||
wdg1.setLayout(l1);
|
||||
wdg1.setWindowTitle("QGridLayout");
|
||||
wdg1.setGeometry(100, 100, 100, 100);
|
||||
wdg1.show();
|
||||
|
||||
QWidget wdg2;
|
||||
QFormLayout *l2 = new QFormLayout();
|
||||
l2->addRow(QString("Label1"), new ReplaceButton());
|
||||
l2->addRow(QString("Label2"), new ReplaceButton());
|
||||
l2->addRow(new ReplaceButton(), new ReplaceButton());
|
||||
wdg2.setLayout(l2);
|
||||
wdg2.setWindowTitle("QFormLayout");
|
||||
wdg2.setGeometry(100 + wdg1.sizeHint().width() + 5, 100, 100, 100);
|
||||
wdg2.show();
|
||||
|
||||
QWidget wdg3;
|
||||
QBoxLayout *l3 = new QVBoxLayout(); // new QHBoxLayout()
|
||||
QStackedLayout *sl = new QStackedLayout();
|
||||
sl->addWidget(new ReplaceButton());
|
||||
sl->addWidget(new ReplaceButton());
|
||||
sl->addWidget(new ReplaceButton());
|
||||
l3->addLayout(sl);
|
||||
l3->addWidget(new StackButtonChange(sl));
|
||||
l3->addWidget(new ReplaceButton());
|
||||
l3->addWidget(new ReplaceButton());
|
||||
wdg3.setLayout(l3);
|
||||
wdg3.setWindowTitle("QStackedLayout + BoxLayout");
|
||||
wdg3.setGeometry(100, 100 + wdg1.sizeHint().height() + 30, 100 , 100);
|
||||
wdg3.show();
|
||||
|
||||
app.exec();
|
||||
}
|
||||
#include "main.moc"
|
15
tests/manual/widgets/kernel/qtooltip/CMakeLists.txt
Normal file
15
tests/manual/widgets/kernel/qtooltip/CMakeLists.txt
Normal file
@ -0,0 +1,15 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## qtooltip Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_manual_test(qtooltip
|
||||
SOURCES
|
||||
main.cpp
|
||||
LIBRARIES
|
||||
Qt::Gui
|
||||
Qt::Test
|
||||
Qt::Widgets
|
||||
)
|
123
tests/manual/widgets/kernel/qtooltip/main.cpp
Normal file
123
tests/manual/widgets/kernel/qtooltip/main.cpp
Normal file
@ -0,0 +1,123 @@
|
||||
// Copyright (C) 2013 Thorbjørn Lund Martsum - tmartsum[at]gmail.com
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include <QTest>
|
||||
#include <QDialog>
|
||||
#include <QToolTip>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
#include <QProxyStyle>
|
||||
#include <QSpinBox>
|
||||
|
||||
class QToolTipTest : public QProxyStyle
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QToolTipTest() : QProxyStyle()
|
||||
{
|
||||
wakeTime = QApplication::style()->styleHint(SH_ToolTip_WakeUpDelay);
|
||||
sleepTime = QApplication::style()->styleHint(SH_ToolTip_FallAsleepDelay);
|
||||
}
|
||||
|
||||
int styleHint(StyleHint hint, const QStyleOption *option = 0, const QWidget *widget = 0,
|
||||
QStyleHintReturn *returnData = 0) const
|
||||
{
|
||||
switch (hint) {
|
||||
case SH_ToolTip_WakeUpDelay:
|
||||
return wakeTime;
|
||||
case SH_ToolTip_FallAsleepDelay:
|
||||
return sleepTime;
|
||||
default:
|
||||
return QProxyStyle::styleHint(hint, option, widget, returnData);
|
||||
}
|
||||
}
|
||||
|
||||
public slots:
|
||||
void setWakeTime(int wake) { wakeTime = wake; }
|
||||
void setSleepTime(int sleep) { sleepTime = sleep; }
|
||||
protected:
|
||||
int wakeTime;
|
||||
int sleepTime;
|
||||
};
|
||||
|
||||
class TestDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TestDialog(QToolTipTest *s);
|
||||
QToolTipTest *style;
|
||||
protected slots:
|
||||
void showSomeToolTips();
|
||||
};
|
||||
|
||||
void TestDialog::showSomeToolTips()
|
||||
{
|
||||
QPoint p(100 + 20, 100 + 20);
|
||||
|
||||
for (int u = 1; u < 20; u += 5) {
|
||||
QString s = tr("Seconds: ") + QString::number(u);
|
||||
QToolTip::showText(p, s, 0, QRect(), 1000 * u);
|
||||
QTest::qWait((u + 1) * 1000);
|
||||
}
|
||||
|
||||
QToolTip::showText(p, tr("Seconds: 2"), 0, QRect(), 2000);
|
||||
QTest::qWait(3000);
|
||||
|
||||
QToolTip::showText(p, tr("Standard label"), 0, QRect());
|
||||
QTest::qWait(12000);
|
||||
}
|
||||
|
||||
TestDialog::TestDialog(QToolTipTest *s) : style(s)
|
||||
{
|
||||
// Notice that these tool tips will disappear if another tool tip is shown.
|
||||
QLabel *label1 = new QLabel(tr("Tooltip - Only two seconds display"));
|
||||
label1->setToolTip(tr("2 seconds display"));
|
||||
label1->setToolTipDuration(2000);
|
||||
Q_ASSERT(label1->toolTipDuration() == 2000);
|
||||
|
||||
QLabel *label2 = new QLabel(tr("Tooltip - 30 seconds display time"));
|
||||
label2->setToolTip(tr("30 seconds display"));
|
||||
label2->setToolTipDuration(30000);
|
||||
|
||||
QPushButton *pb = new QPushButton(tr("&Test"));
|
||||
pb->setToolTip(tr("Show some tool tips."));
|
||||
Q_ASSERT(pb->toolTipDuration() == -1);
|
||||
connect(pb, SIGNAL(clicked()), this, SLOT(showSomeToolTips()));
|
||||
|
||||
QLabel *wakeLabel = new QLabel(tr("Wake Delay:"));
|
||||
QSpinBox *wakeSpinBox = new QSpinBox();
|
||||
wakeSpinBox->setRange(0, 100000);
|
||||
wakeSpinBox->setValue(style->styleHint(QStyle::SH_ToolTip_WakeUpDelay));
|
||||
connect(wakeSpinBox, SIGNAL(valueChanged(int)), style, SLOT(setWakeTime(int)));
|
||||
|
||||
QLabel *sleepLabel = new QLabel(tr("Sleep Delay:"));
|
||||
QSpinBox *sleepSpinBox = new QSpinBox();
|
||||
sleepSpinBox->setRange(0, 100000);
|
||||
sleepSpinBox->setValue(style->styleHint(QStyle::SH_ToolTip_FallAsleepDelay));
|
||||
connect(sleepSpinBox, SIGNAL(valueChanged(int)), style, SLOT(setSleepTime(int)));
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
layout->addWidget(label1);
|
||||
layout->addWidget(label2);
|
||||
layout->addWidget(pb);
|
||||
layout->addWidget(wakeLabel);
|
||||
layout->addWidget(wakeSpinBox);
|
||||
layout->addWidget(wakeLabel);
|
||||
layout->addWidget(sleepLabel);
|
||||
layout->addWidget(sleepSpinBox);
|
||||
|
||||
setLayout(layout);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
QToolTipTest *style = new QToolTipTest();
|
||||
QApplication::setStyle(style);
|
||||
TestDialog dlg(style);
|
||||
dlg.show();
|
||||
return app.exec();
|
||||
}
|
||||
|
||||
#include "main.moc"
|
2
tests/manual/widgets/kernel/qtooltip/qtooltip.pro
Normal file
2
tests/manual/widgets/kernel/qtooltip/qtooltip.pro
Normal file
@ -0,0 +1,2 @@
|
||||
SOURCES = main.cpp
|
||||
QT += widgets testlib
|
15
tests/manual/widgets/kernel/setscreen/CMakeLists.txt
Normal file
15
tests/manual/widgets/kernel/setscreen/CMakeLists.txt
Normal file
@ -0,0 +1,15 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## setscreen Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_manual_test(setscreen
|
||||
GUI
|
||||
SOURCES
|
||||
main.cpp
|
||||
LIBRARIES
|
||||
Qt::Gui
|
||||
Qt::Widgets
|
||||
)
|
108
tests/manual/widgets/kernel/setscreen/main.cpp
Normal file
108
tests/manual/widgets/kernel/setscreen/main.cpp
Normal file
@ -0,0 +1,108 @@
|
||||
// Copyright (C) 2020 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
class ScreenWidget : public QWidget
|
||||
{
|
||||
public:
|
||||
ScreenWidget(QWidget *parent)
|
||||
: QWidget(parent, Qt::Window)
|
||||
{
|
||||
textEdit = new QTextEdit;
|
||||
textEdit->setReadOnly(true);
|
||||
|
||||
QHBoxLayout *layout = new QHBoxLayout;
|
||||
layout->addWidget(textEdit);
|
||||
setLayout(layout);
|
||||
}
|
||||
|
||||
void updateText()
|
||||
{
|
||||
QString text = "<html><body>";
|
||||
text += QString("<p>Screen: %1\n</p>").arg(screen()->name());
|
||||
text += QString("<p>DPR: %1\n</p>").arg(screen()->devicePixelRatio());
|
||||
text += QString("</body></html>");
|
||||
|
||||
textEdit->setText(text);
|
||||
}
|
||||
|
||||
private:
|
||||
QTextEdit *textEdit;
|
||||
};
|
||||
|
||||
class Controller : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Controller()
|
||||
{
|
||||
QPushButton *screenButton = new QPushButton;
|
||||
screenButton->setText("Show on Screen");
|
||||
screenButton->setEnabled(false);
|
||||
connect(screenButton, &QAbstractButton::clicked, this, &Controller::setScreen);
|
||||
|
||||
QPushButton *exitButton = new QPushButton;
|
||||
exitButton->setText("E&xit");
|
||||
connect(exitButton, &QAbstractButton::clicked, QApplication::instance(), &QCoreApplication::quit);
|
||||
|
||||
QHBoxLayout *actionLayout = new QHBoxLayout;
|
||||
actionLayout->addWidget(screenButton);
|
||||
actionLayout->addWidget(exitButton);
|
||||
|
||||
QGroupBox *radioGroup = new QGroupBox;
|
||||
radioGroup->setTitle(QLatin1String("Select target screen"));
|
||||
|
||||
QVBoxLayout *groupLayout = new QVBoxLayout;
|
||||
const auto screens = QGuiApplication::screens();
|
||||
int count = 0;
|
||||
for (const auto &screen : screens) {
|
||||
QRadioButton *choice = new QRadioButton;
|
||||
choice->setText(QString(QLatin1String("%1: %2")).arg(count).arg(screen->name()));
|
||||
connect(choice, &QAbstractButton::toggled, this, [=](bool on){
|
||||
if (on)
|
||||
targetScreen = count;
|
||||
screenButton->setEnabled(targetScreen != -1);
|
||||
});
|
||||
groupLayout->addWidget(choice);
|
||||
++count;
|
||||
}
|
||||
radioGroup->setLayout(groupLayout);
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
layout->addWidget(radioGroup);
|
||||
layout->addLayout(actionLayout);
|
||||
setLayout(layout);
|
||||
}
|
||||
|
||||
private slots:
|
||||
void setScreen()
|
||||
{
|
||||
QScreen *screen = QGuiApplication::screens().at(targetScreen);
|
||||
if (!widget) {
|
||||
widget = new ScreenWidget(this);
|
||||
widget->setAttribute(Qt::WA_DeleteOnClose);
|
||||
widget->setWindowTitle("Normal Window");
|
||||
}
|
||||
widget->setScreen(screen);
|
||||
widget->show();
|
||||
widget->updateText();
|
||||
}
|
||||
|
||||
private:
|
||||
QPointer<ScreenWidget> widget = nullptr;
|
||||
int targetScreen = -1;
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
Controller controller;
|
||||
controller.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
||||
#include "main.moc"
|
3
tests/manual/widgets/kernel/setscreen/setscreen.pro
Normal file
3
tests/manual/widgets/kernel/setscreen/setscreen.pro
Normal file
@ -0,0 +1,3 @@
|
||||
TEMPLATE = app
|
||||
SOURCES = main.cpp
|
||||
QT += widgets
|
16
tests/manual/widgets/kernel/sizeonhide/CMakeLists.txt
Normal file
16
tests/manual/widgets/kernel/sizeonhide/CMakeLists.txt
Normal file
@ -0,0 +1,16 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## sizeonhide Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_manual_test(sizeonhide
|
||||
GUI
|
||||
SOURCES
|
||||
main.cpp
|
||||
LIBRARIES
|
||||
Qt::CorePrivate
|
||||
Qt::Gui
|
||||
Qt::Widgets
|
||||
)
|
96
tests/manual/widgets/kernel/sizeonhide/main.cpp
Normal file
96
tests/manual/widgets/kernel/sizeonhide/main.cpp
Normal file
@ -0,0 +1,96 @@
|
||||
// Copyright (C) 2013 Thorbjørn Martsum - tmartsum[at]gmail.com
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
class KeepSizeExampleDlg : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QGridLayout *gridLayout;
|
||||
QHBoxLayout *horizontalLayout;
|
||||
QVBoxLayout *verticalLayout;
|
||||
QCheckBox *checkBox;
|
||||
QCheckBox *checkBox2;
|
||||
QCheckBox *checkBox3;
|
||||
QCheckBox *checkBox4;
|
||||
QGroupBox *groupBox;
|
||||
QVBoxLayout *verticalLayout2;
|
||||
QRadioButton *radioButton;
|
||||
QRadioButton *radioButton2;
|
||||
QRadioButton *radioButton3;
|
||||
QTableView *tableView;
|
||||
QPushButton *pushButton;
|
||||
QSpacerItem *horizontalSpacer;
|
||||
|
||||
KeepSizeExampleDlg()
|
||||
{
|
||||
QWidget *form = this;
|
||||
form->resize(408, 295);
|
||||
gridLayout = new QGridLayout(form);
|
||||
horizontalLayout = new QHBoxLayout();
|
||||
verticalLayout = new QVBoxLayout();
|
||||
checkBox = new QCheckBox(form);
|
||||
verticalLayout->addWidget(checkBox);
|
||||
checkBox2 = new QCheckBox(form);
|
||||
verticalLayout->addWidget(checkBox2);
|
||||
checkBox3 = new QCheckBox(form);
|
||||
verticalLayout->addWidget(checkBox3);
|
||||
checkBox4 = new QCheckBox(form);
|
||||
verticalLayout->addWidget(checkBox4);
|
||||
horizontalLayout->addLayout(verticalLayout);
|
||||
groupBox = new QGroupBox(form);
|
||||
verticalLayout2 = new QVBoxLayout(groupBox);
|
||||
radioButton = new QRadioButton(groupBox);
|
||||
verticalLayout2->addWidget(radioButton);
|
||||
radioButton2 = new QRadioButton(groupBox);
|
||||
verticalLayout2->addWidget(radioButton2);
|
||||
radioButton3 = new QRadioButton(groupBox);
|
||||
verticalLayout2->addWidget(radioButton3);
|
||||
horizontalLayout->addWidget(groupBox);
|
||||
gridLayout->addLayout(horizontalLayout, 0, 0, 1, 2);
|
||||
tableView = new QTableView(form);
|
||||
gridLayout->addWidget(tableView, 1, 0, 1, 2);
|
||||
pushButton = new QPushButton(form);
|
||||
gridLayout->addWidget(pushButton, 2, 0, 1, 1);
|
||||
horizontalSpacer = new QSpacerItem(340, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
gridLayout->addItem(horizontalSpacer, 2, 1, 1, 1);
|
||||
checkBox->setText(QString::fromUtf8("CheckBox1"));
|
||||
checkBox2->setText(QString::fromUtf8("CheckBox2"));
|
||||
checkBox3->setText(QString::fromUtf8("CheckBox - for client A only"));
|
||||
checkBox4->setText(QString::fromUtf8("CheckBox - also for client A"));
|
||||
groupBox->setTitle(QString::fromUtf8("Mode"));
|
||||
radioButton->setText(QString::fromUtf8("Mode 1"));
|
||||
radioButton2->setText(QString::fromUtf8("Mode 2"));
|
||||
radioButton3->setText(QString::fromUtf8("Mode 3"));
|
||||
pushButton->setText(QString::fromUtf8("&Hide/Show"));
|
||||
|
||||
QObject::connect(pushButton, SIGNAL(clicked()), this, SLOT(showOrHide()));
|
||||
}
|
||||
|
||||
protected slots:
|
||||
void showOrHide()
|
||||
{
|
||||
if (checkBox3->isVisible()) {
|
||||
checkBox3->hide();
|
||||
checkBox4->hide();
|
||||
} else {
|
||||
checkBox3->show();
|
||||
checkBox4->show();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
KeepSizeExampleDlg d;
|
||||
QSizePolicy policyKeepSpace = d.checkBox3->sizePolicy();
|
||||
policyKeepSpace.setRetainSizeWhenHidden(true);
|
||||
d.checkBox3->setSizePolicy(policyKeepSpace);
|
||||
d.checkBox4->setSizePolicy(policyKeepSpace);
|
||||
d.show();
|
||||
app.exec();
|
||||
}
|
||||
|
||||
#include "main.moc"
|
3
tests/manual/widgets/kernel/sizeonhide/sizeonhide.pro
Normal file
3
tests/manual/widgets/kernel/sizeonhide/sizeonhide.pro
Normal file
@ -0,0 +1,3 @@
|
||||
TEMPLATE = app
|
||||
SOURCES = main.cpp
|
||||
QT += widgets core-private
|
4
tests/manual/widgets/qgraphicsview/CMakeLists.txt
Normal file
4
tests/manual/widgets/qgraphicsview/CMakeLists.txt
Normal file
@ -0,0 +1,4 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
add_subdirectory(rubberband)
|
2
tests/manual/widgets/qgraphicsview/qgraphicsview.pro
Normal file
2
tests/manual/widgets/qgraphicsview/qgraphicsview.pro
Normal file
@ -0,0 +1,2 @@
|
||||
TEMPLATE = subdirs
|
||||
SUBDIRS = rubberband
|
15
tests/manual/widgets/qgraphicsview/rubberband/CMakeLists.txt
Normal file
15
tests/manual/widgets/qgraphicsview/rubberband/CMakeLists.txt
Normal file
@ -0,0 +1,15 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## rubberband Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_manual_test(rubberband
|
||||
GUI
|
||||
SOURCES
|
||||
rubberbandtest.cpp
|
||||
LIBRARIES
|
||||
Qt::Gui
|
||||
Qt::Widgets
|
||||
)
|
@ -0,0 +1,3 @@
|
||||
TEMPLATE = app
|
||||
SOURCES = rubberbandtest.cpp
|
||||
QT += gui widgets # core-private
|
@ -0,0 +1,89 @@
|
||||
// Copyright (C) 2012 Thorbjørn Lund Martsum - tmartsum[at]gmail.com
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
class MyGraphicsItem : public QGraphicsRectItem
|
||||
{
|
||||
public:
|
||||
MyGraphicsItem() : QGraphicsRectItem()
|
||||
{
|
||||
setFlags(QGraphicsItem::ItemIsSelectable);
|
||||
}
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem * /* option*/, QWidget * /*widget*/) override
|
||||
{
|
||||
if (isSelected())
|
||||
painter->fillRect(rect(), QColor(255, 0, 0));
|
||||
else
|
||||
painter->fillRect(rect(), QColor(0, 255, 0));
|
||||
}
|
||||
};
|
||||
|
||||
class MyGraphicsView : public QGraphicsView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MyGraphicsView(QWidget *w, QLabel *l) : QGraphicsView(w), rubberbandLabel(l)
|
||||
{
|
||||
setDragMode(QGraphicsView::RubberBandDrag);
|
||||
connect(this, SIGNAL(rubberBandChanged(QRect, QPointF, QPointF)), this, SLOT(updateRubberbandInfo(QRect, QPointF, QPointF)));
|
||||
}
|
||||
protected:
|
||||
void mouseMoveEvent(QMouseEvent *event) override
|
||||
{
|
||||
QGraphicsView::mouseMoveEvent(event);
|
||||
|
||||
int rightmostInView = viewport()->mapToGlobal(viewport()->geometry().topRight()).x();
|
||||
int xglobal = event->globalX();
|
||||
if (xglobal > rightmostInView)
|
||||
horizontalScrollBar()->setValue(horizontalScrollBar()->value() + 10);
|
||||
|
||||
int bottomPos = viewport()->mapToGlobal(viewport()->geometry().bottomRight()).y();
|
||||
int yglobal = event->globalY();
|
||||
if (yglobal > bottomPos)
|
||||
verticalScrollBar()->setValue(verticalScrollBar()->value() + 10);
|
||||
}
|
||||
|
||||
protected slots:
|
||||
void updateRubberbandInfo(QRect r, QPointF from, QPointF to)
|
||||
{
|
||||
QString textToShow;
|
||||
QDebug s(&textToShow);
|
||||
s << r << from << to;
|
||||
rubberbandLabel->setText(textToShow);
|
||||
}
|
||||
protected:
|
||||
QLabel *rubberbandLabel;
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
QWidget w;
|
||||
w.setLayout(new QVBoxLayout);
|
||||
QLabel *l = new QLabel(&w);
|
||||
MyGraphicsView *v = new MyGraphicsView(&w, l);
|
||||
|
||||
w.layout()->addWidget(v);
|
||||
w.layout()->addWidget(l);
|
||||
|
||||
QGraphicsScene s(0.0, 0.0, 5000.0, 5000.0);
|
||||
v->setScene(&s);
|
||||
v->setInteractive(true);
|
||||
v->setRubberBandSelectionMode(Qt::IntersectsItemBoundingRect);
|
||||
|
||||
for (int u = 0; u < 100; ++u)
|
||||
for (int n = 0; n < 100; ++n) {
|
||||
MyGraphicsItem *item = new MyGraphicsItem();
|
||||
item->setRect(QRectF(n * 80.0, u * 80.0, 50.0, 20.0));
|
||||
s.addItem(item);
|
||||
}
|
||||
|
||||
w.show();
|
||||
app.exec();
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include "rubberbandtest.moc"
|
13
tests/manual/widgets/styles/CMakeLists.txt
Normal file
13
tests/manual/widgets/styles/CMakeLists.txt
Normal file
@ -0,0 +1,13 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## tst_manual_styles Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_manual_test(tst_manual_styles
|
||||
SOURCES
|
||||
main.cpp
|
||||
LIBRARIES
|
||||
Qt::Widgets
|
||||
)
|
282
tests/manual/widgets/styles/main.cpp
Normal file
282
tests/manual/widgets/styles/main.cpp
Normal file
@ -0,0 +1,282 @@
|
||||
// Copyright (C) 2017 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include <QAction>
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QGridLayout>
|
||||
#include <QGroupBox>
|
||||
#include <QLabel>
|
||||
#include <QList>
|
||||
#include <QMainWindow>
|
||||
#include <QMenu>
|
||||
#include <QMenuBar>
|
||||
#include <QPalette>
|
||||
#include <QPixmap>
|
||||
#include <QPlainTextEdit>
|
||||
#include <QScreen>
|
||||
#include <QStyle>
|
||||
#include <QTabWidget>
|
||||
#include <QTextStream>
|
||||
#include <QVBoxLayout>
|
||||
#include <QWindow>
|
||||
|
||||
// Format enumeration value and strip off the class name
|
||||
// added by QDebug: "QStyle::StandardPixmap(SP_Icon)" -> "SP_Icon".
|
||||
template <typename Enum>
|
||||
static inline QString formatEnumValue(Enum value)
|
||||
{
|
||||
QString result;
|
||||
QDebug(&result) << value;
|
||||
int index = result.indexOf(QLatin1Char('('));
|
||||
if (index > 0) { // "QStyle::StandardPixmap(..)".
|
||||
result.remove(0, index + 1);
|
||||
index = result.lastIndexOf(QLatin1Char(')'));
|
||||
if (index > 0)
|
||||
result.truncate(index);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static QTextStream &operator<<(QTextStream &str, const QSize &s)
|
||||
{
|
||||
str << s.width();
|
||||
if (s.width() != s.height())
|
||||
str << 'x' << s.height();
|
||||
return str;
|
||||
}
|
||||
|
||||
struct StyleIconEntry
|
||||
{
|
||||
QString name;
|
||||
QStyle::StandardPixmap pixmap;
|
||||
};
|
||||
|
||||
static bool operator<(const StyleIconEntry &e1, const StyleIconEntry &e2)
|
||||
{
|
||||
return e1.name < e2.name;
|
||||
}
|
||||
|
||||
static QList<StyleIconEntry> styleIconEntries()
|
||||
{
|
||||
QList<StyleIconEntry> result;
|
||||
const int count = int(QStyle::SP_LineEditClearButton) + 1;
|
||||
result.reserve(count);
|
||||
for (int i = 0; i < count; ++i) {
|
||||
QStyle::StandardPixmap px = static_cast<QStyle::StandardPixmap>(i);
|
||||
result.append({formatEnumValue(px), px});
|
||||
}
|
||||
std::sort(result.begin(), result.end());
|
||||
return result;
|
||||
}
|
||||
|
||||
class IconDisplayWidget : public QGroupBox
|
||||
{
|
||||
public:
|
||||
explicit IconDisplayWidget(const QString &title, const QString &text,
|
||||
const QPixmap &pixmap, QWidget *p = nullptr);
|
||||
};
|
||||
|
||||
IconDisplayWidget::IconDisplayWidget(const QString &title, const QString &text,
|
||||
const QPixmap &pixmap, QWidget *p)
|
||||
: QGroupBox(title, p)
|
||||
{
|
||||
QHBoxLayout *hLayout = new QHBoxLayout(this);
|
||||
hLayout->addWidget(new QLabel(text, this));
|
||||
QLabel *iconLabel = new QLabel(this);
|
||||
iconLabel->setPixmap(pixmap);
|
||||
hLayout->addWidget(iconLabel);
|
||||
}
|
||||
|
||||
static IconDisplayWidget *createStandardPixmapDisplay(const StyleIconEntry &e, QWidget *parent)
|
||||
{
|
||||
QPixmap pixmap = parent->style()->standardPixmap(e.pixmap, nullptr, parent);
|
||||
QString description;
|
||||
QTextStream str(&description);
|
||||
str << pixmap.size();
|
||||
return new IconDisplayWidget(e.name, description, pixmap, parent);
|
||||
}
|
||||
|
||||
enum : int { maxColumns = 6 };
|
||||
|
||||
// Display pixmaps returned by QStyle::standardPixmap() in a grid.
|
||||
static QWidget *createStandardPixmapPage(QWidget *parent)
|
||||
{
|
||||
QWidget *result = new QWidget(parent);
|
||||
QGridLayout *grid = new QGridLayout(result);
|
||||
int row = 0;
|
||||
int column = 0;
|
||||
QList<StyleIconEntry> entries = styleIconEntries();
|
||||
for (int i = 0, size = entries.size(); i < size; ++i) {
|
||||
grid->addWidget(createStandardPixmapDisplay(entries.at(i), parent), row, column++);
|
||||
if (column >= maxColumns) {
|
||||
++row;
|
||||
column = 0;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Display icons returned by QStyle::standardIcon() in a grid.
|
||||
static IconDisplayWidget *createStandardIconDisplay(const StyleIconEntry &e,
|
||||
const QSize &displaySize,
|
||||
QWidget *parent)
|
||||
{
|
||||
QIcon icon = parent->style()->standardIcon(e.pixmap, nullptr, parent);
|
||||
QString description;
|
||||
QTextStream str(&description);
|
||||
auto availableSizes = icon.availableSizes();
|
||||
std::sort(availableSizes.begin(), availableSizes.end(),
|
||||
[](QSize s1, QSize s2) { return s1.width() < s2.width(); });
|
||||
for (int i =0; i < availableSizes.size(); ++i) {
|
||||
if (i)
|
||||
str << ',';
|
||||
str << availableSizes.at(i);
|
||||
}
|
||||
return new IconDisplayWidget(e.name, description, icon.pixmap(displaySize), parent);
|
||||
}
|
||||
|
||||
static QWidget *createStandardIconPage(QWidget *parent)
|
||||
{
|
||||
QWidget *result = new QWidget(parent);
|
||||
QGridLayout *grid = new QGridLayout(result);
|
||||
int row = 0;
|
||||
int column = 0;
|
||||
const int largeIconSize = parent->style()->pixelMetric(QStyle::PM_LargeIconSize);
|
||||
const QSize displaySize(largeIconSize, largeIconSize);
|
||||
QList<StyleIconEntry> entries = styleIconEntries();
|
||||
for (int i = 0, size = entries.size(); i < size; ++i) {
|
||||
grid->addWidget(createStandardIconDisplay(entries.at(i), displaySize, parent), row, column++);
|
||||
if (column >= maxColumns) {
|
||||
++row;
|
||||
column = 0;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Display values returned by QStyle::pixelMetric().
|
||||
static QWidget *createMetricsPage(QWidget *parent)
|
||||
{
|
||||
QPlainTextEdit *result = new QPlainTextEdit(parent);
|
||||
QString text;
|
||||
QTextStream str(&text);
|
||||
for (int i = 0; i <= int(QStyle::PM_HeaderDefaultSectionSizeVertical); ++i) {
|
||||
const QStyle::PixelMetric m = static_cast<QStyle::PixelMetric>(i);
|
||||
str << formatEnumValue(m) << '(' << int(m) << ")="
|
||||
<< result->style()->pixelMetric(m, nullptr, result) << '\n';
|
||||
}
|
||||
result->setPlainText(text);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Display values returned by QStyle::styleHint()
|
||||
static QWidget *createHintsPage(QWidget *parent)
|
||||
{
|
||||
QPlainTextEdit *result = new QPlainTextEdit(parent);
|
||||
QString text;
|
||||
QTextStream str(&text);
|
||||
for (int i = 0; i <= int(QStyle::SH_Menu_SubMenuDontStartSloppyOnLeave); ++i) {
|
||||
const QStyle::StyleHint h = static_cast<QStyle::StyleHint>(i);
|
||||
str << formatEnumValue(h) << '(' << int(h) << ")="
|
||||
<< result->style()->styleHint(h, nullptr, result) << '\n';
|
||||
}
|
||||
result->setPlainText(text);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Display palette colors
|
||||
static QWidget *createColorsPage(QWidget *parent)
|
||||
{
|
||||
QWidget *result = new QWidget(parent);
|
||||
QGridLayout *grid = new QGridLayout;
|
||||
const QPalette palette = QGuiApplication::palette();
|
||||
for (int r = 0; r < int(QPalette::NColorRoles); ++r) {
|
||||
const QPalette::ColorRole role = static_cast<QPalette::ColorRole>(r);
|
||||
const QString description =
|
||||
formatEnumValue(role) + QLatin1Char('(') + QString::number(r)
|
||||
+ QLatin1String(") ") + palette.color(QPalette::Active, role).name(QColor::HexArgb);
|
||||
grid->addWidget(new QLabel(description), r, 0);
|
||||
int col = 1;
|
||||
for (int g : {QPalette::Active, QPalette::Inactive, QPalette::Disabled}) {
|
||||
const QColor color = palette.color(QPalette::ColorGroup(g), role);
|
||||
if (color.isValid()) {
|
||||
QLabel *displayLabel = new QLabel;
|
||||
QPixmap pixmap(20, 20);
|
||||
pixmap.fill(color);
|
||||
displayLabel->setPixmap(pixmap);
|
||||
displayLabel->setFrameShape(QFrame::Box);
|
||||
grid->addWidget(displayLabel, r, col);
|
||||
}
|
||||
++col;
|
||||
}
|
||||
}
|
||||
QHBoxLayout *hBox = new QHBoxLayout;
|
||||
hBox->addLayout(grid);
|
||||
hBox->addStretch();
|
||||
QVBoxLayout *vBox = new QVBoxLayout(result);
|
||||
vBox->addLayout(hBox);
|
||||
vBox->addStretch();
|
||||
return result;
|
||||
}
|
||||
|
||||
class MainWindow : public QMainWindow {
|
||||
Q_OBJECT
|
||||
public:
|
||||
MainWindow();
|
||||
|
||||
public slots:
|
||||
void updateDescription();
|
||||
|
||||
private:
|
||||
QTabWidget *m_tabWidget;
|
||||
QLabel *m_descriptionLabel;
|
||||
};
|
||||
|
||||
MainWindow::MainWindow()
|
||||
: m_tabWidget(new QTabWidget)
|
||||
, m_descriptionLabel(new QLabel)
|
||||
{
|
||||
QMenu *fileMenu = menuBar()->addMenu("&File");
|
||||
QAction *a = fileMenu->addAction("Quit", this, &QWidget::close);
|
||||
a->setShortcut(Qt::CTRL | Qt::Key_Q);
|
||||
|
||||
QWidget *central = new QWidget;
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout(central);
|
||||
mainLayout->addWidget(m_descriptionLabel);
|
||||
mainLayout->addWidget(m_tabWidget);
|
||||
m_tabWidget->addTab(createStandardIconPage(m_tabWidget), "Standard Icon");
|
||||
m_tabWidget->addTab(createStandardPixmapPage(m_tabWidget), "Standard Pixmaps");
|
||||
m_tabWidget->addTab(createHintsPage(m_tabWidget), "Hints");
|
||||
m_tabWidget->addTab(createMetricsPage(m_tabWidget), "Pixel Metrics");
|
||||
m_tabWidget->addTab(createColorsPage(m_tabWidget), "Colors");
|
||||
setCentralWidget(central);
|
||||
|
||||
setWindowTitle(QLatin1String("Style Tester (Qt") + QLatin1String(QT_VERSION_STR)
|
||||
+ QLatin1String(", ") + style()->objectName() + QLatin1Char(')'));
|
||||
}
|
||||
|
||||
void MainWindow::updateDescription()
|
||||
{
|
||||
QString text;
|
||||
QTextStream str(&text);
|
||||
str << "Qt " << QT_VERSION_STR << ", platform: " << QGuiApplication::platformName()
|
||||
<< ", Style: \"" << style()->objectName() << "\", DPR=" << devicePixelRatio()
|
||||
<< ' ' << logicalDpiX() << ',' << logicalDpiY() << "DPI";
|
||||
if (const QWindow *w = windowHandle())
|
||||
str << ", Screen: \"" << w->screen()->name() << '"';
|
||||
m_descriptionLabel->setText(text);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
MainWindow mw;
|
||||
mw.show();
|
||||
mw.updateDescription();
|
||||
QObject::connect(mw.windowHandle(), &QWindow::screenChanged,
|
||||
&mw, &MainWindow::updateDescription);
|
||||
return app.exec();
|
||||
}
|
||||
|
||||
#include "main.moc"
|
7
tests/manual/widgets/styles/styles.pro
Normal file
7
tests/manual/widgets/styles/styles.pro
Normal file
@ -0,0 +1,7 @@
|
||||
TEMPLATE = app
|
||||
QT = widgets
|
||||
TARGET = tst_manual_styles
|
||||
CONFIG += cmdline
|
||||
CONFIG += c++11
|
||||
|
||||
SOURCES += main.cpp
|
2
tests/manual/widgets/widgets.pro
Normal file
2
tests/manual/widgets/widgets.pro
Normal file
@ -0,0 +1,2 @@
|
||||
TEMPLATE = subdirs
|
||||
SUBDIRS = itemviews qgraphicsview kernel widgets styles
|
8
tests/manual/widgets/widgets/CMakeLists.txt
Normal file
8
tests/manual/widgets/widgets/CMakeLists.txt
Normal file
@ -0,0 +1,8 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
add_subdirectory(bigmenucreator)
|
||||
add_subdirectory(defaultUpMenuBar)
|
||||
add_subdirectory(multiscreen-menus)
|
||||
add_subdirectory(qtoolbutton/menuOnMultiScreens)
|
||||
add_subdirectory(qtabbar)
|
20
tests/manual/widgets/widgets/bigmenucreator/CMakeLists.txt
Normal file
20
tests/manual/widgets/widgets/bigmenucreator/CMakeLists.txt
Normal file
@ -0,0 +1,20 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## BigMenuCreator Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_manual_test(BigMenuCreator
|
||||
GUI
|
||||
SOURCES
|
||||
main.cpp
|
||||
mainwindow.cpp mainwindow.h mainwindow.ui
|
||||
DEFINES
|
||||
QT_DEPRECATED_WARNINGS
|
||||
LIBRARIES
|
||||
Qt::Gui
|
||||
Qt::Widgets
|
||||
ENABLE_AUTOGEN_TOOLS
|
||||
uic
|
||||
)
|
@ -0,0 +1,32 @@
|
||||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2017-10-19T16:07:04
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += core gui widgets
|
||||
|
||||
TARGET = BigMenuCreator
|
||||
TEMPLATE = app
|
||||
|
||||
# The following define makes your compiler emit warnings if you use
|
||||
# any feature of Qt which as been marked as deprecated (the exact warnings
|
||||
# depend on your compiler). Please consult the documentation of the
|
||||
# deprecated API in order to know how to port your code away from it.
|
||||
DEFINES += QT_DEPRECATED_WARNINGS
|
||||
|
||||
# You can also make your code fail to compile if you use deprecated APIs.
|
||||
# In order to do so, uncomment the following line.
|
||||
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_UP_TO=0x060000 # disables all APIs deprecated in Qt 6.0.0 and earlier
|
||||
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
mainwindow.cpp
|
||||
|
||||
HEADERS += \
|
||||
mainwindow.h
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui
|
29
tests/manual/widgets/widgets/bigmenucreator/main.cpp
Normal file
29
tests/manual/widgets/widgets/bigmenucreator/main.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
// Copyright (C) 2017 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 <QApplication>
|
||||
#include <QCommandLineParser>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
|
||||
QCommandLineParser parser;
|
||||
parser.setApplicationDescription("BigMenuCreator");
|
||||
parser.addHelpOption();
|
||||
parser.addOptions({
|
||||
{ "new-menubar", QLatin1String("Use new menubar instead of QMainWindow's own.") },
|
||||
{ "no-parent", QLatin1String("When using a new menubar, do *not* set its parent on construction.") }
|
||||
});
|
||||
|
||||
parser.process(a);
|
||||
|
||||
MainWindow::newMenubar = parser.isSet("new-menubar");
|
||||
MainWindow::parentlessMenubar = parser.isSet("no-parent");
|
||||
|
||||
MainWindow w;
|
||||
w.show();
|
||||
|
||||
return a.exec();
|
||||
}
|
114
tests/manual/widgets/widgets/bigmenucreator/mainwindow.cpp
Normal file
114
tests/manual/widgets/widgets/bigmenucreator/mainwindow.cpp
Normal file
@ -0,0 +1,114 @@
|
||||
// Copyright (C) 2017 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 "ui_mainwindow.h"
|
||||
|
||||
bool MainWindow::newMenubar = false;
|
||||
bool MainWindow::parentlessMenubar = false;
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::MainWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
const int level = 3;
|
||||
QMenuBar *mb;
|
||||
if (newMenubar)
|
||||
mb = new QMenuBar(parentlessMenubar ? nullptr : this);
|
||||
else
|
||||
mb = ui->menuBar;
|
||||
populateMenu(mb, level);
|
||||
if (newMenubar)
|
||||
setMenuBar(mb);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
// We do all the permutations on the following 3 operations:
|
||||
//
|
||||
// A: Add action to parent menu
|
||||
// P: Populate the submenu
|
||||
// S: Set action submenu
|
||||
//
|
||||
// Recursing on menu population gives more combinations of
|
||||
// creation and insertions.
|
||||
|
||||
void MainWindow::populateMenu(QWidget *menu, int level)
|
||||
{
|
||||
if (level > 0) {
|
||||
--level;
|
||||
doAPS(menu, level);
|
||||
doASP(menu, level);
|
||||
doPAS(menu, level);
|
||||
doSPA(menu, level);
|
||||
doSAP(menu, level);
|
||||
doPSA(menu, level);
|
||||
} else {
|
||||
static int itemCounter = 0;
|
||||
static const char *sym[] = { "Foo", "Bar", "Baz", "Quux" };
|
||||
for (uint i = 0; i < sizeof(sym) / sizeof(sym[0]); i++) {
|
||||
QString title = QString::fromLatin1("%1 Item %2").arg(QLatin1String(sym[i])).arg(itemCounter);
|
||||
menu->addAction(new QAction(title));
|
||||
}
|
||||
++itemCounter;
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::doAPS(QWidget *menu, int level)
|
||||
{
|
||||
auto *action = new QAction("A P S");
|
||||
menu->addAction(action);
|
||||
auto *submenu = new QMenu;
|
||||
populateMenu(submenu, level);
|
||||
action->setMenu(submenu);
|
||||
}
|
||||
|
||||
void MainWindow::doASP(QWidget *menu, int level)
|
||||
{
|
||||
auto *action = new QAction("A S P");
|
||||
menu->addAction(action);
|
||||
auto *submenu = new QMenu;
|
||||
action->setMenu(submenu);
|
||||
populateMenu(submenu, level);
|
||||
}
|
||||
|
||||
void MainWindow::doPAS(QWidget *menu, int level)
|
||||
{
|
||||
auto *submenu = new QMenu;
|
||||
populateMenu(submenu, level);
|
||||
auto *action = new QAction("P A S");
|
||||
menu->addAction(action);
|
||||
action->setMenu(submenu);
|
||||
}
|
||||
|
||||
void MainWindow::doSPA(QWidget *menu, int level)
|
||||
{
|
||||
auto *action = new QAction("S P A");
|
||||
auto *submenu = new QMenu;
|
||||
action->setMenu(submenu);
|
||||
populateMenu(submenu, level);
|
||||
menu->addAction(action);
|
||||
}
|
||||
|
||||
void MainWindow::doSAP(QWidget *menu, int level)
|
||||
{
|
||||
auto *action = new QAction("S A P");
|
||||
auto *submenu = new QMenu;
|
||||
action->setMenu(submenu);
|
||||
menu->addAction(action);
|
||||
populateMenu(submenu, level);
|
||||
}
|
||||
|
||||
void MainWindow::doPSA(QWidget *menu, int level)
|
||||
{
|
||||
auto *action = new QAction("P S A");
|
||||
auto *submenu = new QMenu;
|
||||
populateMenu(submenu, level);
|
||||
action->setMenu(submenu);
|
||||
menu->addAction(action);
|
||||
}
|
38
tests/manual/widgets/widgets/bigmenucreator/mainwindow.h
Normal file
38
tests/manual/widgets/widgets/bigmenucreator/mainwindow.h
Normal file
@ -0,0 +1,38 @@
|
||||
// Copyright (C) 2017 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>
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
|
||||
void doAPS(QWidget *menu, int level);
|
||||
void doASP(QWidget *menu, int level);
|
||||
void doPAS(QWidget *menu, int level);
|
||||
|
||||
void doSPA(QWidget *menu, int level);
|
||||
void doSAP(QWidget *menu, int level);
|
||||
void doPSA(QWidget *menu, int level);
|
||||
|
||||
void populateMenu(QWidget *menu, int level);
|
||||
|
||||
static bool newMenubar;
|
||||
static bool parentlessMenubar;
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
74
tests/manual/widgets/widgets/bigmenucreator/mainwindow.ui
Normal file
74
tests/manual/widgets/widgets/bigmenucreator/mainwindow.ui
Normal file
@ -0,0 +1,74 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>427</width>
|
||||
<height>372</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>16</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'.SF NS Text'; font-size:16pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt;">We do all the permutations on the following 3 operations:</span></p>
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:14pt;"><br /></p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt; font-weight:600;"> A</span><span style=" font-size:14pt;">: Add action to parent menu</span></p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt; font-weight:600;"> P</span><span style=" font-size:14pt;">: Populate the submenu</span></p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt; font-weight:600;"> S</span><span style=" font-size:14pt;">: Set action submenu</span></p>
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:14pt;"><br /></p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt;">This gets repeated 2 menu levels from the menubar. All menus and items are enabled and should show as such.</span></p>
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:14pt;"><br /></p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt;">The order of menus is APS, ASP, PAS, SPA, SAP, PSA.</span></p>
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:14pt;"><br /></p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt;">The order of terminal items is &quot;Foo&quot;, &quot;Bar&quot;, &quot;Baz&quot;, &quot;Quux&quot;.</span></p>
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:14pt;"><br /></p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt;">Rerun with &quot;--new-menubar&quot; and &quot;--no-parent&quot; to force using a new menubar instead of QMainWindow's own, with or without parent. QMainWindow::setMenuBar() will be called regardless of the parent option.</span></p></body></html></string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menuBar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>427</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="mainToolBar">
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
16
tests/manual/widgets/widgets/defaultUpMenuBar/CMakeLists.txt
Normal file
16
tests/manual/widgets/widgets/defaultUpMenuBar/CMakeLists.txt
Normal file
@ -0,0 +1,16 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## defaultUpMenuBar Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_manual_test(defaultUpMenuBar
|
||||
GUI
|
||||
SOURCES
|
||||
main.cpp
|
||||
LIBRARIES
|
||||
Qt::Gui
|
||||
Qt::GuiPrivate
|
||||
Qt::Widgets
|
||||
)
|
@ -0,0 +1,4 @@
|
||||
QT += widgets gui-private
|
||||
TEMPLATE = app
|
||||
TARGET = defaultUpMenuBar
|
||||
SOURCES += main.cpp
|
84
tests/manual/widgets/widgets/defaultUpMenuBar/main.cpp
Normal file
84
tests/manual/widgets/widgets/defaultUpMenuBar/main.cpp
Normal file
@ -0,0 +1,84 @@
|
||||
// Copyright (C) 2018 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||||
|
||||
// This test is to check that the menus in a menubar are displayed correctly in both the top and
|
||||
// bottom cases. Especially when using multiple screens. If possible relayout the screens in order
|
||||
// to have one that is entirely in negative coordinates (i.e. the primary starts at 0x0 and the
|
||||
// secondary is above it).
|
||||
|
||||
#include <QtWidgets>
|
||||
#include <QtGui/qpa/qplatformwindow.h>
|
||||
#include <QtGui/qpa/qplatformwindow_p.h>
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
public:
|
||||
MainWindow(QWidget *parent = nullptr) : QMainWindow(parent)
|
||||
{
|
||||
auto *menu1Act1 = new QAction("Action 1");
|
||||
auto *menu1Act2 = new QAction("Action 2");
|
||||
auto *menu1Act3 = new QAction("Action 3");
|
||||
auto *menu1Act4 = new QAction("Action 4");
|
||||
auto *menu2Act1 = new QAction("2- Action 1");
|
||||
auto *menu2Act2 = new QAction("2- Action 2");
|
||||
auto *menu2Act3 = new QAction("2- Action 3");
|
||||
auto *menu2Act4 = new QAction("2- Action 4");
|
||||
auto *menu1 = new QMenu("Menu 1");
|
||||
menu1->addAction(menu1Act1);
|
||||
menu1->addAction(menu1Act2);
|
||||
menu1->addAction(menu1Act3);
|
||||
menu1->addAction(menu1Act4);
|
||||
auto *menu2 = new QMenu("Menu 2");
|
||||
menu2->addAction(menu2Act1);
|
||||
menu2->addAction(menu2Act2);
|
||||
menu2->addAction(menu2Act3);
|
||||
menu2->addAction(menu2Act4);
|
||||
menuBar()->addMenu(menu1);
|
||||
menuBar()->addMenu(menu2);
|
||||
menuBar()->setNativeMenuBar(false);
|
||||
|
||||
auto *menu1Bottom = new QMenu("Menu 1");
|
||||
menu1Bottom->addAction(menu1Act1);
|
||||
menu1Bottom->addAction(menu1Act2);
|
||||
menu1Bottom->addAction(menu1Act3);
|
||||
menu1Bottom->addAction(menu1Act4);
|
||||
auto *menu2Bottom = new QMenu("Menu 2");
|
||||
menu2Bottom->addAction(menu2Act1);
|
||||
menu2Bottom->addAction(menu2Act2);
|
||||
menu2Bottom->addAction(menu2Act3);
|
||||
menu2Bottom->addAction(menu2Act4);
|
||||
|
||||
QWidget *central = new QWidget;
|
||||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
auto *menuBarBottom = new QMenuBar(this);
|
||||
menuBarBottom->addMenu(menu1Bottom);
|
||||
menuBarBottom->addMenu(menu2Bottom);
|
||||
menuBarBottom->setDefaultUp(true);
|
||||
menuBarBottom->setNativeMenuBar(false);
|
||||
layout->addWidget(menuBarBottom);
|
||||
layout->setAlignment(menuBarBottom, Qt::AlignBottom);
|
||||
central->setLayout(layout);
|
||||
setCentralWidget(central);
|
||||
setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
|
||||
}
|
||||
};
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
QList<MainWindow *> windows;
|
||||
for (QScreen *screen : QApplication::screens()) {
|
||||
MainWindow *mainWindow = new MainWindow;
|
||||
mainWindow->setGeometry(screen->geometry());
|
||||
mainWindow->winId();
|
||||
#ifdef Q_OS_WIN
|
||||
using namespace QNativeInterface::Private;
|
||||
if (auto *windowsWindow = dynamic_cast<QWindowsWindow *>(mainWindow->windowHandle()->handle()))
|
||||
windowsWindow->setHasBorderInFullScreen(true);
|
||||
#endif
|
||||
mainWindow->showMaximized();
|
||||
}
|
||||
int ret = a.exec();
|
||||
qDeleteAll(windows);
|
||||
return ret;
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## multiscreen-menus Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_manual_test(multiscreen-menus
|
||||
GUI
|
||||
SOURCES
|
||||
main.cpp
|
||||
mainwindow.cpp mainwindow.h mainwindow.ui
|
||||
LIBRARIES
|
||||
Qt::Gui
|
||||
Qt::Widgets
|
||||
ENABLE_AUTOGEN_TOOLS
|
||||
uic
|
||||
)
|
16
tests/manual/widgets/widgets/multiscreen-menus/main.cpp
Normal file
16
tests/manual/widgets/widgets/multiscreen-menus/main.cpp
Normal file
@ -0,0 +1,16 @@
|
||||
// Copyright (C) 2017 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 <QApplication>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
a.setAttribute(Qt::AA_DontUseNativeMenuBar);
|
||||
|
||||
MainWindow w;
|
||||
w.show();
|
||||
|
||||
return a.exec();
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
// Copyright (C) 2017 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 "ui_mainwindow.h"
|
||||
#include <QtGui/QtEvents>
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::MainWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setStyleSheet("QMenu { menu-scrollable: 0 }");
|
||||
|
||||
auto *mb = new QMenuBar(this);
|
||||
setMenuBar(mb);
|
||||
|
||||
auto *m = new QMenu(mb);
|
||||
m->setTitle("&Menu");
|
||||
m->setTearOffEnabled(true);
|
||||
|
||||
for (int i = 0; i < 80; ++i)
|
||||
m->addAction("Menu Item #" + QString::number(i));
|
||||
|
||||
mb->addMenu(m);
|
||||
|
||||
ui->menuButton->setMenu(m);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void MainWindow::contextMenuEvent(QContextMenuEvent *e)
|
||||
{
|
||||
const auto *mb = menuBar();
|
||||
mb->actions().first()->menu()->popup(mb->mapToGlobal(e->pos()));
|
||||
}
|
27
tests/manual/widgets/widgets/multiscreen-menus/mainwindow.h
Normal file
27
tests/manual/widgets/widgets/multiscreen-menus/mainwindow.h
Normal file
@ -0,0 +1,27 @@
|
||||
// Copyright (C) 2017 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>
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
|
||||
void contextMenuEvent(QContextMenuEvent *e) override;
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
86
tests/manual/widgets/widgets/multiscreen-menus/mainwindow.ui
Normal file
86
tests/manual/widgets/widgets/multiscreen-menus/mainwindow.ui
Normal file
@ -0,0 +1,86 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>427</width>
|
||||
<height>228</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Move this window to a secondary screen, ideally with a larger size than the primary screen.
|
||||
|
||||
Open menu bar, button and context menus. The menu contents should be consistent with the screen it's being displayed on.
|
||||
|
||||
Tear-off the menu and move around across screens. The torn-off menu should adapt to the screen size.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="menuButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Menu Button</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>18</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Right-click for context menu</string>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignHCenter|Qt::AlignTop</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menuBar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>427</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -0,0 +1,9 @@
|
||||
TEMPLATE = app
|
||||
QT += core gui widgets
|
||||
|
||||
SOURCES += main.cpp\
|
||||
mainwindow.cpp
|
||||
|
||||
HEADERS += mainwindow.h
|
||||
|
||||
FORMS += mainwindow.ui
|
@ -0,0 +1,15 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## saveStateSize Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_manual_test(saveStateSize
|
||||
GUI
|
||||
SOURCES
|
||||
main.cpp
|
||||
LIBRARIES
|
||||
Qt::Gui
|
||||
Qt::Widgets
|
||||
)
|
@ -0,0 +1,86 @@
|
||||
// Copyright (C) 2019 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
// Test that the size of the saved state bytearray does not change due to moving a
|
||||
// toolbar from one area to another. It should stay the same size as the first time
|
||||
// it had that toolbar in it
|
||||
|
||||
#include <QApplication>
|
||||
#include <QMainWindow>
|
||||
#include <QToolBar>
|
||||
#include <QPushButton>
|
||||
#include <QLabel>
|
||||
#include <QVBoxLayout>
|
||||
#include <QMessageBox>
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MainWindow() : QMainWindow()
|
||||
{
|
||||
auto *tb = new QToolBar(this);
|
||||
tb->setObjectName("Toolbar");
|
||||
tb->addAction("Test action");
|
||||
tb->addAction("Test action");
|
||||
addToolBar(Qt::TopToolBarArea, tb);
|
||||
auto *movableTb = new QToolBar(this);
|
||||
movableTb->setObjectName("Movable Toolbar");
|
||||
movableTb->addAction("Test action");
|
||||
movableTb->addAction("Test action");
|
||||
addToolBar(Qt::TopToolBarArea, movableTb);
|
||||
auto *widget = new QWidget;
|
||||
auto *vbox = new QVBoxLayout;
|
||||
auto *label = new QLabel;
|
||||
label->setText("1. Click on check state size to save initial state\n"
|
||||
"2. Drag the movable toolbar in the top dock area to the left area."
|
||||
" Click on check state size to save moved state\n"
|
||||
"3. Drag the movable toolbar from the left dock area to the top area."
|
||||
" Click on check state size to compare the state sizes.\n"
|
||||
"4. Drag the movable toolbar in the top dock area to the left area."
|
||||
" Click on check state size to compare the state sizes.\n"
|
||||
"5. Drag the movable toolbar from the left dock area to the top area."
|
||||
" Click on check state size to compare the state sizes.\n");
|
||||
vbox->addWidget(label);
|
||||
auto *pushButton = new QPushButton("Check state size");
|
||||
connect(pushButton, &QPushButton::clicked, this, &MainWindow::checkState);
|
||||
vbox->addWidget(pushButton);
|
||||
widget->setLayout(vbox);
|
||||
setCentralWidget(widget);
|
||||
}
|
||||
public slots:
|
||||
void checkState()
|
||||
{
|
||||
stepCounter++;
|
||||
QString messageText;
|
||||
if (stepCounter == 1) {
|
||||
beforeMoveStateData = saveState();
|
||||
messageText = QLatin1String("Initial state saved");
|
||||
} else if (stepCounter == 2) {
|
||||
afterMoveStateData = saveState();
|
||||
messageText = QLatin1String("Moved state saved");
|
||||
} else {
|
||||
const int currentSaveSize = saveState().size();
|
||||
const int compareValue = (stepCounter == 4) ? afterMoveStateData.size() : beforeMoveStateData.size();
|
||||
messageText = QString::fromLatin1("%1 step %2")
|
||||
.arg((currentSaveSize == compareValue) ? QLatin1String("SUCCESS") : QLatin1String("FAIL"))
|
||||
.arg(stepCounter);
|
||||
}
|
||||
QMessageBox::information(this, "Step done", messageText);
|
||||
}
|
||||
private:
|
||||
int stepCounter = 0;
|
||||
QByteArray beforeMoveStateData;
|
||||
QByteArray afterMoveStateData;
|
||||
};
|
||||
|
||||
#include "main.moc"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
MainWindow mw;
|
||||
mw.show();
|
||||
return a.exec();
|
||||
}
|
||||
|
@ -0,0 +1,4 @@
|
||||
QT += widgets
|
||||
TEMPLATE = app
|
||||
TARGET = saveStateSize
|
||||
SOURCES += main.cpp
|
4
tests/manual/widgets/widgets/qtabbar/CMakeLists.txt
Normal file
4
tests/manual/widgets/widgets/qtabbar/CMakeLists.txt
Normal file
@ -0,0 +1,4 @@
|
||||
# Copyright (C) 2023 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
add_subdirectory(stylesheet)
|
1
tests/manual/widgets/widgets/qtabbar/qtabbar.pro
Normal file
1
tests/manual/widgets/widgets/qtabbar/qtabbar.pro
Normal file
@ -0,0 +1 @@
|
||||
SUBDIRS = stylesheet
|
@ -0,0 +1,15 @@
|
||||
# Copyright (C) 2023 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## qtabbar Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_manual_test(qtabbar
|
||||
GUI
|
||||
SOURCES
|
||||
main.cpp
|
||||
LIBRARIES
|
||||
Qt::Gui
|
||||
Qt::Widgets
|
||||
)
|
24
tests/manual/widgets/widgets/qtabbar/stylesheet/main.cpp
Normal file
24
tests/manual/widgets/widgets/qtabbar/stylesheet/main.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
// Copyright (C) 2020 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||||
|
||||
// This test is for checking that when there is padding set on the stylesheet and the elide mode is
|
||||
// set that it is correctly shown as elided and not clipped.
|
||||
|
||||
#include <QApplication>
|
||||
#include <QTabBar>
|
||||
#include <QIcon>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
app.setStyleSheet("QTabBar::tab { padding-left: 20px; }\n");
|
||||
QIcon icon(":/v.ico");
|
||||
|
||||
QTabBar b;
|
||||
b.setElideMode(Qt::ElideRight);
|
||||
b.addTab(icon, "some text");
|
||||
b.resize(80,32);
|
||||
b.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
5
tests/manual/widgets/widgets/qtabbar/stylesheet/res.qrc
Normal file
5
tests/manual/widgets/widgets/qtabbar/stylesheet/res.qrc
Normal file
@ -0,0 +1,5 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>v.ico</file>
|
||||
</qresource>
|
||||
</RCC>
|
@ -0,0 +1,5 @@
|
||||
QT += widgets
|
||||
TEMPLATE = app
|
||||
TARGET = stylesheet
|
||||
RESOURCES += res.qrc
|
||||
SOURCES += main.cpp
|
BIN
tests/manual/widgets/widgets/qtabbar/stylesheet/v.ico
Normal file
BIN
tests/manual/widgets/widgets/qtabbar/stylesheet/v.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
@ -0,0 +1,15 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## menuOnMultiScreens Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_manual_test(menuOnMultiScreens
|
||||
GUI
|
||||
SOURCES
|
||||
main.cpp
|
||||
LIBRARIES
|
||||
Qt::Gui
|
||||
Qt::Widgets
|
||||
)
|
@ -0,0 +1,48 @@
|
||||
// Copyright (C) 2017 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
// This tests that when in a multiple screen setup, that screens that have a top-left of 0x0 or
|
||||
// a top left of being above/below the other screen then showing the toolbutton menu will be
|
||||
// placed correctly.
|
||||
|
||||
#include <QApplication>
|
||||
#include <QMainWindow>
|
||||
#include <QToolBar>
|
||||
#include <QToolButton>
|
||||
#include <QMenu>
|
||||
#include <QScreen>
|
||||
|
||||
class MyMainWindow : public QMainWindow
|
||||
{
|
||||
public:
|
||||
MyMainWindow(QWidget *parent = nullptr) : QMainWindow(parent)
|
||||
{
|
||||
auto *toolBar = new QToolBar;
|
||||
QPixmap pix(16, 16);
|
||||
pix.fill(Qt::red);
|
||||
auto *button = new QToolButton;
|
||||
button->setIcon(pix);
|
||||
toolBar->addWidget(button);
|
||||
auto *menu = new QMenu(button);
|
||||
for (int i = 0; i < 10; ++i)
|
||||
menu->addAction(QString("Test Action %1").arg(i));
|
||||
button->setMenu(menu);
|
||||
addToolBar(toolBar);
|
||||
}
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
QList<MyMainWindow *> windows;
|
||||
for (QScreen *s : a.screens()) {
|
||||
MyMainWindow *w = new MyMainWindow;
|
||||
w->setGeometry(s->availableGeometry());
|
||||
w->show();
|
||||
windows << w;
|
||||
}
|
||||
int ret = a.exec();
|
||||
qDeleteAll(windows);
|
||||
return ret;
|
||||
}
|
||||
|
@ -0,0 +1,3 @@
|
||||
TEMPLATE = app
|
||||
QT += widgets
|
||||
SOURCES += main.cpp
|
6
tests/manual/widgets/widgets/widgets.pro
Normal file
6
tests/manual/widgets/widgets/widgets.pro
Normal file
@ -0,0 +1,6 @@
|
||||
TEMPLATE = subdirs
|
||||
SUBDIRS = bigmenucreator \
|
||||
defaultUpMenuBar \
|
||||
multiscreen-menus \
|
||||
qtoolbutton/menuOnMultiScreens \
|
||||
qtabbar
|
Reference in New Issue
Block a user