From 8512ed1a06888a98f71367f4ac3da3f6edc945c3 Mon Sep 17 00:00:00 2001 From: Arno Date: Sat, 3 Feb 2018 08:02:05 +0100 Subject: Implement alternating row colors Once again, surprisingly difficult, as you can see on the number of changed files. Coding the configuration options wasn't that difficult, but actually using them was. As it turned out, the default style on Windows doesn't use QApplication::palette() at all, though it does honor setAlternatingRowColors(). It just doesn't use the palette colors, but style sheets. Took me a while to figure out. So, there's always another layer of indirection: First, add all QTreeViews to Globals::views, then create a helper to set the style sheet. --- searchdialog.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'searchdialog.cpp') diff --git a/searchdialog.cpp b/searchdialog.cpp index e30ead6..50109b9 100644 --- a/searchdialog.cpp +++ b/searchdialog.cpp @@ -17,6 +17,7 @@ #include "searchdialog.h" #include "searchview.h" #include "helper.h" +#include "globals.h" SearchDialog::SearchDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f){ //search bar @@ -42,6 +43,7 @@ SearchDialog::SearchDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, QSortFilterProxyModel *resMProxy = new QSortFilterProxyModel; resMProxy->setSourceModel(mResM); mResV = new SearchView; + Globals::instance()->addView(mResV); mResV->setModel(resMProxy); connect(mResV->selectionModel(), &QItemSelectionModel::currentChanged, this, &SearchDialog::doResult); QHBoxLayout *resGBL = new QHBoxLayout; @@ -52,6 +54,7 @@ SearchDialog::SearchDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, QSortFilterProxyModel *dataMProxy = new QSortFilterProxyModel; dataMProxy->setSourceModel(mDataM); mDataV = new SearchView; + Globals::instance()->addView(mDataV); mDataV->setModel(dataMProxy); QHBoxLayout *dataGBL = new QHBoxLayout; dataGBL->addWidget(mDataV); -- cgit v1.2.3-70-g09d2