qtablewidgetitem

Qt - Cannot put an image in a table

那年仲夏 提交于 2019-11-28 01:42:14
问题 Why with the following code I just get an empty table widget? QString imgPath = "C:\\path\\to\\image.jpg"; QImage *img = new QImage(imgPath); QTableWidget *thumbnailsWidget = new QTableWidget; QTableWidgetItem *thumbnail = new QTableWidgetItem; thumbnail->setData(Qt::DecorationRole, QPixmap::fromImage(*img)); thumbnailsWidget->setColumnCount(5); thumbnailsWidget->setRowCount(3); thumbnailsWidget->setItem(0, 0, thumbnail); setCentralWidget(thumbnailsWidget); How can I put an image into a

how to add a right click menu to each cell of QTableView in PyQt

别等时光非礼了梦想. 提交于 2019-11-27 11:44:41
问题 I want to add a right click menu to delete, rename or open image in each of cell of QTAbleView in the rigt click menu, I have tried and found everyone is trying to add menu to a header in tableview, i tried below but that seems not working in the code below.. class GalleryUi(QtGui.QTableView): """ Class contains the methods that forms the UI of Image galery """ def __init__(self, imagesPathLst=None, parent=None): super(GalleryUi, self).__init__(parent) self.__sw = QtGui.QDesktopWidget()

QTableWidget Integer

大城市里の小女人 提交于 2019-11-27 03:40:23
问题 I am trying to insert and display integers in my QTableWidget. They don't display. It works if I convert everything to strings, but then I can't sort columns numerically--only lexically (1, 10, 100, etc.). This is using PyQt. I've tried some of the suggested solutions, using QTableWidgetItem.setData(someRole,intValue), bu then nothing at all displays. I've tried, Qt.UserRole, DisplayRole and Edit Role. (I don't understand why these Roles are needed to display integers, but have just followed