Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

qtablewidget add image

from PyQt4 import QtGui
import sys

imagePath = "enter the path to your image here"

class ImgWidget1(QtGui.QLabel):

    def __init__(self, parent=None):
        super(ImgWidget1, self).__init__(parent)
        pic = QtGui.QPixmap(imagePath)
        self.setPixmap(pic)

class ImgWidget2(QtGui.QWidget):

    def __init__(self, parent=None):
        super(ImgWidget2, self).__init__(parent)
        self.pic = QtGui.QPixmap(imagePath)

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


class Widget(QtGui.QWidget):

    def __init__(self):
        super(Widget, self).__init__()
        tableWidget = QtGui.QTableWidget(10, 2, self)
        tableWidget.setCellWidget(0, 1, ImgWidget1(self))
        tableWidget.setCellWidget(1, 1, ImgWidget2(self))

if __name__ == "__main__":
    app = QtGui.QApplication([])
    wnd = Widget()
    wnd.show()
    sys.exit(app.exec_())
Comment

qtablewidget add image


from PyQt4 import QtGui
import sys

imagePath = "enter the path to your image here"

class ImgWidget1(QtGui.QLabel):

    def __init__(self, parent=None):
        super(ImgWidget1, self).__init__(parent)
        pic = QtGui.QPixmap(imagePath)
        self.setPixmap(pic)

class ImgWidget2(QtGui.QWidget):

    def __init__(self, parent=None):
        super(ImgWidget2, self).__init__(parent)
        self.pic = QtGui.QPixmap(imagePath)

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


class Widget(QtGui.QWidget):

    def __init__(self):
        super(Widget, self).__init__()
        tableWidget = QtGui.QTableWidget(10, 2, self)
        tableWidget.setCellWidget(0, 1, ImgWidget1(self))
        tableWidget.setCellWidget(1, 1, ImgWidget2(self))

if __name__ == "__main__":
    app = QtGui.QApplication([])
    wnd = Widget()
    wnd.show()
    sys.exit(app.exec_())

Comment

PREVIOUS NEXT
Code Example
Csharp :: how to disable vsync in monogame 
Csharp :: ffmpeg add audio to video at specific time 
Csharp :: how use vue createApp 
Csharp :: array of strings by splitting lines c# 
Csharp :: top level statements c# 
Csharp :: c# array.join 
Csharp :: c# multiple strings are empty 
Csharp :: list to array c# 
Csharp :: minimize window windows forms application c# 
Csharp :: C# return and set multiple values from method 
Csharp :: datetime empty date 
Csharp :: c# get battery level 
Csharp :: c# array of class 
Csharp :: check property type of collection c# 
Csharp :: unity sort a list 
Csharp :: linq query get last day of month 
Csharp :: c# switch case greater than 
Csharp :: unity rotate around axis 
Csharp :: Terrain Tools unity missing 
Csharp :: c# remove duplicates from list 
Csharp :: bsod screen c# 
Csharp :: To CharArray 
Csharp :: make 2D object move at constant speed unity 
Csharp :: c# string to float 
Csharp :: unity respawn c# 
Csharp :: linq foreach c# 
Csharp :: C# compare date values 
Csharp :: remove item from list in for loop c# 
Csharp :: c# const vs readonly 
Csharp :: how to add data in list in c# 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =