Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7796813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:29:08+00:00 2026-06-01T23:29:08+00:00

I tried sub-classing the QTableWidgetItem and then set my horizontalHeaderItem with that new sub-classed

  • 0

I tried sub-classing the QTableWidgetItem and then set my horizontalHeaderItem with that new sub-classed class. for instance:

class ImageWidget(QtGui.QTableWidgetItem):

def __init__(self, imagePath, parent):
    super(ImageWidget, self).__init__(parent)
    self.picture = QtGui.QPixmap(imagePath)

def paintEvent(self, event):
    painter = QtGui.QPainter(self)
    painter.drawPixmap(0, 0, self.picture)

class showTable(QtGui.QDialog):

def __init__(self, parent=None):
    tableWidget = QtGui.QTableWidget(10, 2)
    imagePath = "C:/Documents and Settings/pwr37669/workspace/Pro_GUI_Py/images/led_green.gif"
    item = ImageWidget(imagePath, QtGui.QTableWidgetItem())
    tableWidget.setHorizontalHeaderItem(0, item)

    tableWidget.show() 

I know that code won’t work, but, I’m trying to get something like that to work.

I also need to change the results of clicking on a cell or the header.

Any help would be greatly appreciated.
Thanks,
Stephen

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T23:29:09+00:00Added an answer on June 1, 2026 at 11:29 pm

    The following seems to do the trick:

    class ImgWidget1(QtGui.QLabel):
    
        def __init__(self,imagePath, parent=None):
            super(ImgWidget1, self).__init__(parent)
    
            pic = QtGui.QPixmap(imagePath)
            self.setAlignment(QtCore.Qt.AlignCenter)
            self.setPixmap(pic)
    

    And then when I wanted to add an image I did this:

    self.tableWidget.setCellWidget(rows, cells, ui_polling.ImgWidget1(imagePath))
    

    Hope this helps someone out there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In order to place my models in sub-folders I tried to use the app_label
tried to research on that but sometimes I seem to lack some googling skills...
I currently have a model set up like so: I have a Test class
I tried to LogCGRect(cell.textLabel.frame); but that just gives me (0, 0) 0 x 0
I want to set an editable column in QTableView , so far I tried
i am new to QT, i tried lot searching samples of how to get
I have a class, lets call it A, and within that class definition I
I'm trying to have all my views inherit from a custom class so that
Tried following the instructions here: How to use Google app engine with my own
Tried this: $('.link').click(function(e) { $.getScript('http://www.google.com/uds/api?file=uds.js&amp;v=1.0', function() { $('body').append('<p>GOOGLE API (UDS) is loaded</p>'); }); return

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.