summaryrefslogtreecommitdiffstats
path: root/examples/widgets/widgets
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2020-01-04 15:32:34 +0100
committerLiang Qi <liang.qi@qt.io>2020-01-04 15:32:34 +0100
commita503bf54705d89204007e8f887b668fe5ef519fc (patch)
treeb2d1a452da39450eac78a1aeb1df116a73f64b23 /examples/widgets/widgets
parente65c43fd0ffa57248e7d750570b7deae171a82f5 (diff)
parent1f87fb359fdff14e42662384a9c8a0bcb3837671 (diff)
Merge remote-tracking branch 'origin/5.15' into dev
Conflicts: src/corelib/tools/qvector.h Make QVector(DataPointer dd) public to be able to properly merge 5b4b437b30b320e2cd7c9a566999a39772e5d431 from 5.15 into dev. src/widgets/kernel/qapplication.cpp tests/auto/tools/moc/allmocs_baseline_in.json Done-With: Christian Ehrlicher <ch.ehrlicher@gmx.de> Change-Id: I929ba7c036d570382d0454c2c75f6f0d96ddbc01
Diffstat (limited to 'examples/widgets/widgets')
-rw-r--r--examples/widgets/widgets/charactermap/mainwindow.cpp2
-rw-r--r--examples/widgets/widgets/icons/mainwindow.cpp2
-rw-r--r--examples/widgets/widgets/styles/main.cpp3
-rw-r--r--examples/widgets/widgets/styles/norwegianwoodstyle.cpp1
-rw-r--r--examples/widgets/widgets/styles/widgetgallery.cpp26
-rw-r--r--examples/widgets/widgets/styles/widgetgallery.h4
-rw-r--r--examples/widgets/widgets/tablet/mainwindow.cpp6
-rw-r--r--examples/widgets/widgets/validators/localeselector.cpp2
8 files changed, 36 insertions, 10 deletions
diff --git a/examples/widgets/widgets/charactermap/mainwindow.cpp b/examples/widgets/widgets/charactermap/mainwindow.cpp
index b0f9705c21..702b50156b 100644
--- a/examples/widgets/widgets/charactermap/mainwindow.cpp
+++ b/examples/widgets/widgets/charactermap/mainwindow.cpp
@@ -201,7 +201,7 @@ void MainWindow::findStyles(const QFont &font)
void MainWindow::filterChanged(int f)
{
const QFontComboBox::FontFilter filter =
- filterCombo->itemData(f).value<QFontComboBox::FontFilter>();
+ qvariant_cast<QFontComboBox::FontFilter>(filterCombo->itemData(f));
fontCombo->setFontFilters(filter);
statusBar()->showMessage(tr("%n font(s) found", nullptr, fontCombo->count()));
}
diff --git a/examples/widgets/widgets/icons/mainwindow.cpp b/examples/widgets/widgets/icons/mainwindow.cpp
index 8e61260041..4f990f7320 100644
--- a/examples/widgets/widgets/icons/mainwindow.cpp
+++ b/examples/widgets/widgets/icons/mainwindow.cpp
@@ -361,7 +361,7 @@ QWidget *MainWindow::createImagesGroupBox()
QVBoxLayout *layout = new QVBoxLayout(imagesGroupBox);
layout->addWidget(imagesTable);
return imagesGroupBox;
-//! [25]
+//! [24]
}
//! [26]
diff --git a/examples/widgets/widgets/styles/main.cpp b/examples/widgets/widgets/styles/main.cpp
index d340719984..471589d3ad 100644
--- a/examples/widgets/widgets/styles/main.cpp
+++ b/examples/widgets/widgets/styles/main.cpp
@@ -50,12 +50,15 @@
#include <QApplication>
+#include "norwegianwoodstyle.h"
#include "widgetgallery.h"
int main(int argc, char *argv[])
{
Q_INIT_RESOURCE(styles);
+ QApplication::setStyle(new NorwegianWoodStyle);
+
QApplication app(argc, argv);
WidgetGallery gallery;
gallery.show();
diff --git a/examples/widgets/widgets/styles/norwegianwoodstyle.cpp b/examples/widgets/widgets/styles/norwegianwoodstyle.cpp
index 0f614a2e9a..bbdb626a18 100644
--- a/examples/widgets/widgets/styles/norwegianwoodstyle.cpp
+++ b/examples/widgets/widgets/styles/norwegianwoodstyle.cpp
@@ -58,6 +58,7 @@
NorwegianWoodStyle::NorwegianWoodStyle() :
QProxyStyle(QStyleFactory::create("windows"))
{
+ setObjectName("NorwegianWood");
}
//! [0]
diff --git a/examples/widgets/widgets/styles/widgetgallery.cpp b/examples/widgets/widgets/styles/widgetgallery.cpp
index 7e1616c6c0..d70c503f53 100644
--- a/examples/widgets/widgets/styles/widgetgallery.cpp
+++ b/examples/widgets/widgets/styles/widgetgallery.cpp
@@ -143,6 +143,7 @@ WidgetGallery::WidgetGallery(QWidget *parent)
setLayout(mainLayout);
setWindowTitle(tr("Styles"));
+ styleChanged();
}
//! [4]
@@ -150,12 +151,10 @@ WidgetGallery::WidgetGallery(QWidget *parent)
void WidgetGallery::changeStyle(const QString &styleName)
//! [5] //! [6]
{
- if (styleName == "NorwegianWood") {
+ if (styleName == "NorwegianWood")
QApplication::setStyle(new NorwegianWoodStyle);
- } else {
+ else
QApplication::setStyle(QStyleFactory::create(styleName));
- }
- changePalette();
}
//! [6]
@@ -170,6 +169,25 @@ void WidgetGallery::changePalette()
}
//! [8]
+void WidgetGallery::changeEvent(QEvent *event)
+{
+ if (event->type() == QEvent::StyleChange)
+ styleChanged();
+}
+
+void WidgetGallery::styleChanged()
+{
+ auto styleName = QApplication::style()->objectName();
+ for (int i = 0; i < styleComboBox->count(); ++i) {
+ if (QString::compare(styleComboBox->itemText(i), styleName, Qt::CaseInsensitive) == 0) {
+ styleComboBox->setCurrentIndex(i);
+ break;
+ }
+ }
+
+ changePalette();
+}
+
//! [9]
void WidgetGallery::advanceProgressBar()
//! [9] //! [10]
diff --git a/examples/widgets/widgets/styles/widgetgallery.h b/examples/widgets/widgets/styles/widgetgallery.h
index 9ee65c21c4..4deee6839a 100644
--- a/examples/widgets/widgets/styles/widgetgallery.h
+++ b/examples/widgets/widgets/styles/widgetgallery.h
@@ -80,8 +80,12 @@ class WidgetGallery : public QDialog
public:
WidgetGallery(QWidget *parent = nullptr);
+protected:
+ void changeEvent(QEvent *) override;
+
private slots:
void changeStyle(const QString &styleName);
+ void styleChanged();
void changePalette();
void advanceProgressBar();
diff --git a/examples/widgets/widgets/tablet/mainwindow.cpp b/examples/widgets/widgets/tablet/mainwindow.cpp
index 8bcb9ada63..c5b631ee44 100644
--- a/examples/widgets/widgets/tablet/mainwindow.cpp
+++ b/examples/widgets/widgets/tablet/mainwindow.cpp
@@ -85,21 +85,21 @@ void MainWindow::setBrushColor()
//! [2]
void MainWindow::setAlphaValuator(QAction *action)
{
- m_canvas->setAlphaChannelValuator(action->data().value<TabletCanvas::Valuator>());
+ m_canvas->setAlphaChannelValuator(qvariant_cast<TabletCanvas::Valuator>(action->data()));
}
//! [2]
//! [3]
void MainWindow::setLineWidthValuator(QAction *action)
{
- m_canvas->setLineWidthType(action->data().value<TabletCanvas::Valuator>());
+ m_canvas->setLineWidthType(qvariant_cast<TabletCanvas::Valuator>(action->data()));
}
//! [3]
//! [4]
void MainWindow::setSaturationValuator(QAction *action)
{
- m_canvas->setColorSaturationValuator(action->data().value<TabletCanvas::Valuator>());
+ m_canvas->setColorSaturationValuator(qvariant_cast<TabletCanvas::Valuator>(action->data()));
}
//! [4]
diff --git a/examples/widgets/widgets/validators/localeselector.cpp b/examples/widgets/widgets/validators/localeselector.cpp
index 1382da0cc9..3dcd04d9ff 100644
--- a/examples/widgets/widgets/validators/localeselector.cpp
+++ b/examples/widgets/widgets/validators/localeselector.cpp
@@ -90,6 +90,6 @@ void LocaleSelector::emitLocaleSelected(int index)
QVariant v = itemData(index);
if (!v.isValid())
return;
- const QLocale l = v.value<QLocale>();
+ const QLocale l = qvariant_cast<QLocale>(v);
emit localeSelected(l);
}