Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
5.1.1, 5.2.0 Beta1
-
None
-
Windows 7
-
9f779088f434901cd4b81f90fc00e3b34601e071
Description
Even though the fusion style should be platform independent, I think some of its functions should work as they do on the platform below.
On Windows the ascending list has a header arrow pointing up and on a descending list it is pointing down. Where as on Linux (tested on Ubuntu 12.04) the header arrows work the opposite.
The code snippet below can be used to reproduce the issue:
#include <QApplication> #include <QTreeWidget> #include <QHeaderView> #include <QDebug> int main(int argc, char *argv[]) { QApplication app(argc, argv); app.setStyle("Fusion"); qDebug() << app.style(); QTreeWidget *treeWidget = new QTreeWidget(); treeWidget->setColumnCount(1); QList<QTreeWidgetItem *> items; for (int i = 0; i < 10; ++i) items.append(new QTreeWidgetItem((QTreeWidget*)0, QStringList(QString("item: %1").arg(i)))); treeWidget->insertTopLevelItems(0, items); treeWidget->setSortingEnabled(true); //treeWidget->header()->setSortIndicator(0, Qt::AscendingOrder); treeWidget->show(); return app.exec(); }
Expected result on Windows:
The header arrow should point down in case of descending list
Actual result on Windows:
The header arrow points up
This is done in QFusionStyle::drawPrimitive()
case PE_IndicatorHeaderArrow: if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) { QRect r = header->rect; QPixmap arrow; QColor arrowColor = header->palette.foreground().color(); QPoint offset = QPoint(0, -1); if (header->sortIndicator & QStyleOptionHeader::SortUp) { arrow = colorizedImage(QLatin1String(":/qt-project.org/styles/commonstyle/images/fusion_arrow.png"), arrowColor); } else if (header->sortIndicator & QStyleOptionHeader::SortDown) { arrow = colorizedImage(QLatin1String(":/qt-project.org/styles/commonstyle/images/fusion_arrow.png"), arrowColor, 180); } if (!arrow.isNull()) { r.setSize(QSize(arrow.width()/2, arrow.height()/2)); r.moveCenter(header->rect.center()); painter->drawPixmap(r.translated(offset), arrow); } }
As a workaround one can rotate the fusion_arrow.png in case of QStyleOptionHeader::SortUp and not to rotate in case of QStyleOptionHeader::SortDown if the platform is Q_OS_WIN.