Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Call for Presentations - Qt World Summit

    Unsolved QTableView QHeaderView Sorted Column Style.

    General and Desktop
    2
    4
    1070
    Loading More Posts
    • 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.
    • David.Reznicek
      David.Reznicek last edited by

      Hello,

      I would like to change text color in header if column is sorted. I try to use style:

      QHeaderView::section:checked{color: red;}

      QTableView settings:

      table->setSortingEnabled(true);

      Exists any easy way ho to set this text color via stylesheet?

      Thanks, David.

      raven-worx 1 Reply Last reply Reply Quote 0
      • raven-worx
        raven-worx Moderators @David.Reznicek last edited by

        @David.Reznicek
        I think this is not possible using stylesheets.

        But you should be able to achieve what you want in your model.
        By reimplementing headerData() and for the Qt::ForegroundRole return your desired QColor if the section is sorted. Otherwise return the result from the base class implementation.

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        David.Reznicek 1 Reply Last reply Reply Quote 1
        • David.Reznicek
          David.Reznicek last edited by

          This post is deleted!
          1 Reply Last reply Reply Quote 0
          • David.Reznicek
            David.Reznicek @raven-worx last edited by

            @raven-worx Thanks a alot....it works. Better than my workaround to override paintSection in QHeaderView.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post