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. Center align the icon in QAbstractItemView using stylesheets
Forum Updated to NodeBB v4.3 + New Features

Center align the icon in QAbstractItemView using stylesheets

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 5.4k Views 1 Watching
  • 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.
  • S Offline
    S Offline
    spsingh
    wrote on last edited by
    #1

    I have a custom model for a table view. My data function returns a QImage for the decoration role. But this image is not center aligned (horizontally and vertically). I tried using the following style sheet. But the image is still not centered. Please help.

    QAbstractItemView::icon {
    border: 1px solid black;
    }

    QAbstractItemView {
    subcontrol-position: center center;
    }

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DenisKormalev
      wrote on last edited by
      #2

      Try to use QAbstractItemView::item

      1 Reply Last reply
      0
      • S Offline
        S Offline
        spsingh
        wrote on last edited by
        #3

        I tried using it in the following ways but these did not work as well.

        QAbstractItemView::item {
        subcontrol-position: center center;
        }

        And

        QAbstractItemView::item::icon {
        subcontrol-position: center center;
        }

        1 Reply Last reply
        0

        • Login

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