Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QHeaderView when I set up and down arrow image , then header text will not drawtext with aligncenter
Forum Updated to NodeBB v4.3 + New Features

QHeaderView when I set up and down arrow image , then header text will not drawtext with aligncenter

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 292 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    General Yang
    wrote on 27 Dec 2024, 07:36 last edited by
    #1

    HeaderView_Bug.png
    my QT version is 6.8.0, using visual studio 2022
    When I user styleSheet ,then Column 3 Text will not draw in center.
    my sample code:
    int main(int argc, char argv[])
    {
    QApplication a(argc, argv);
    QWidget window;
    QFrame
    pFrame = new QFrame(&window);
    pFrame->setFixedSize(500, 500);
    QVBoxLayout* layout = new QVBoxLayout(pFrame);
    QTableView* pList = new QTableView(pFrame);
    pList->setFixedSize(400, 400);
    pList->setWordWrap(false);
    pList->setShowGrid(false);
    pList->setSelectionBehavior(QAbstractItemView::SelectRows);
    pList->setSortingEnabled(true);
    pList->setAlternatingRowColors(true);
    pList->horizontalHeader()->setStyleSheet("QHeaderView::down-arrow{image:url(:/test/image/arrow_down.png);}
    QHeaderView::up-arrow{image:url(:/test/image/arrow_up.png);}");
    pList->horizontalHeader()->setDefaultAlignment(Qt::AlignCenter);
    QStandardItemModel model(5, 5);
    model.setHorizontalHeaderLabels(QStringList() << "Column 1" << "Column 2" << "Column 3" << "Column 4" << "Column 5");
    for (int row = 0; row < 5; ++row)
    {
    for (int column = 0; column < 5; ++column)
    {
    QStandardItem* item = new QStandardItem(QString("Row%1, Col%2").arg(row + 1).arg(column + 1));
    model.setItem(row, column, item);
    }
    }
    pList->setModel(&model);
    window.show();
    return a.exec();
    }

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 27 Dec 2024, 13:26 last edited by
      #2

      That's a problem of the windowsvista style which draws the arrows on top of the header instead to the right (like all others) and QStyleSheetStyle does not know this/can not know it. Don't know how to fix it though.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      G 1 Reply Last reply 29 Dec 2024, 01:38
      1
      • C Christian Ehrlicher
        27 Dec 2024, 13:26

        That's a problem of the windowsvista style which draws the arrows on top of the header instead to the right (like all others) and QStyleSheetStyle does not know this/can not know it. Don't know how to fix it though.

        G Offline
        G Offline
        General Yang
        wrote on 29 Dec 2024, 01:38 last edited by
        #3

        @Christian-Ehrlicher Yes, it is window style show, when linux the arrow is in Header Text right, how to set to arrow to right under window system? Thanks.

        1 Reply Last reply
        0

        1/3

        27 Dec 2024, 07:36

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved