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. Stretch/Resize background image of QTableWidgetItem

Stretch/Resize background image of QTableWidgetItem

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 1.5k 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.
  • H Offline
    H Offline
    hizoka
    wrote on last edited by hizoka
    #1

    Hi,

    I have a new question for you :)

    In a QTableWidget, I create QTableWidgetItems with a backgroung image.
    I would like as the image resize with the size of the QTableWidgetItem.

    I change the size of the cells but the image never resizing.

    I can not do it...

    Objet = QTableWidgetItem()
    Objet.setData(Qt.BackgroundRole, QBrush(Img))
    

    I prefere do not use QLabel with stretch...

    Any idea ?

    Thank you.

    EDIT :
    For the moment, I use the resizeEvent of the QTableWidget and resend all pixmap with the good width.
    That works but seems heavy...

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      Hi
      did you try to scale Img ?
      Objet.setData(Qt.BackgroundRole, QBrush(Img.scaled(xx)))

      1 Reply Last reply
      0
      • H Offline
        H Offline
        hizoka
        wrote on last edited by
        #3

        Hi, thanks for your reply.

        It's what I use in the resizeEvent (scaledToWidth).

        So, Is it no way option for auto scaled the background image when the cell size change without use the resizeEvent ?

        mrjjM 1 Reply Last reply
        0
        • H hizoka

          Hi, thanks for your reply.

          It's what I use in the resizeEvent (scaledToWidth).

          So, Is it no way option for auto scaled the background image when the cell size change without use the resizeEvent ?

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @hizoka
          Hi
          I never saw such option to have it do it automatically.
          You could try with a delegate
          https://stackoverflow.com/questions/7416503/howto-draw-border-for-qtablewidget-row
          where you handle the drawing of the img yourself.

          Maybe someone knows an easier way :)

          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