diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2009-04-14 09:44:56 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-04-14 12:56:39 (GMT) |
commit | b15ec327df81f8b0d4934ee2f52a7ccc6a8281c2 (patch) | |
tree | d9312c63e75bd05c094d6c9ebf67a6942813ee4f /tests/auto | |
parent | 91aeceb7132f4afae0996443a162a5783d8f17aa (diff) | |
download | Qt-b15ec327df81f8b0d4934ee2f52a7ccc6a8281c2.zip Qt-b15ec327df81f8b0d4934ee2f52a7ccc6a8281c2.tar.gz Qt-b15ec327df81f8b0d4934ee2f52a7ccc6a8281c2.tar.bz2 |
Fixes: QTreeView font change regression if there is an application stylesheet
The way font propagation work has changed since 4.4: When there is a
stylesheet enabled, font does not propagate.
So when settings a font to the QAbstractItemView, the viewport font will
not change, and hence no QEvent::FontChange on it.
So catch the QEvent::FontChange in QAbstractItemView::event in addition
to QAbstractItemView::viewportEvent. (we seems to use the view's font
everywhere anyway)
Task-number: 250754
Reviewed-by: Jens Bache-Wiig
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qabstractitemview/tst_qabstractitemview.cpp | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/tests/auto/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/qabstractitemview/tst_qabstractitemview.cpp index 3337a49..086c551 100644 --- a/tests/auto/qabstractitemview/tst_qabstractitemview.cpp +++ b/tests/auto/qabstractitemview/tst_qabstractitemview.cpp @@ -53,6 +53,8 @@ #include <qspinbox.h> #include <qitemdelegate.h> #include <qpushbutton.h> +#include <qscrollbar.h> +#include <qboxlayout.h> #include "../../shared/util.h" //TESTED_CLASS= @@ -209,6 +211,7 @@ private slots: void setCurrentIndex(); void task221955_selectedEditor(); + void task250754_fontChange(); }; class MyAbstractItemDelegate : public QAbstractItemDelegate @@ -1179,8 +1182,46 @@ void tst_QAbstractItemView::task221955_selectedEditor() button->setFocus(); QTest::qWait(50); QVERIFY(tree.selectionModel()->selectedIndexes().isEmpty()); +} + +void tst_QAbstractItemView::task250754_fontChange() +{ + QString app_css = qApp->styleSheet(); + qApp->setStyleSheet("/* */"); + + QWidget w; + QTreeView tree(&w); + QVBoxLayout *vLayout = new QVBoxLayout(&w); + vLayout->addWidget(&tree); + + QStandardItemModel *m = new QStandardItemModel(this); + for (int i=0; i<5; ++i) { + QStandardItem *item = new QStandardItem(QString("Item number %1").arg(i)); + for (int j=0; j<5; ++j) { + QStandardItem *child = new QStandardItem(QString("Child Item number %1").arg(j)); + item->setChild(j, 0, child); + } + m->setItem(i, 0, item); + } + tree.setModel(m); + + w.show(); + w.resize(150,150); + QTest::qWait(30); + QFont font = tree.font(); + font.setPointSize(5); + tree.setFont(font); + QTest::qWait(30); + + QVERIFY(!tree.verticalScrollBar()->isVisible()); + + font.setPointSize(45); + tree.setFont(font); + QTest::qWait(30); + //now with the huge items, the scrollbar must be visible + QVERIFY(tree.verticalScrollBar()->isVisible()); - + qApp->setStyleSheet(app_css); } QTEST_MAIN(tst_QAbstractItemView) |