qt 6.5.1 original

This commit is contained in:
kleuter
2023-10-29 23:33:08 +01:00
parent 71d22ab6b0
commit 85d238dfda
21202 changed files with 5499099 additions and 0 deletions

View 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)

View File

@ -0,0 +1,2 @@
TEMPLATE = subdirs
SUBDIRS = qtooltip sizeonhide layoutreplace setscreen

View 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
)

View File

@ -0,0 +1,2 @@
SOURCES = main.cpp
QT += widgets

View 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"

View 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
)

View 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"

View File

@ -0,0 +1,2 @@
SOURCES = main.cpp
QT += widgets testlib

View 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
)

View 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"

View File

@ -0,0 +1,3 @@
TEMPLATE = app
SOURCES = main.cpp
QT += widgets

View 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
)

View 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"

View File

@ -0,0 +1,3 @@
TEMPLATE = app
SOURCES = main.cpp
QT += widgets core-private