qtableview

How to get a QTableView to fill 100% of the width?

对着背影说爱祢 提交于 2019-11-29 01:53:12
问题 Here's a print screen of my software: As you can see, the first QTableVIew headers do not take 100% of the width. In fact, there is a small vertical white space on the right of the field size . How can I get the headers to take 100% of the width of the QTableView ? 回答1: If you are using Qt 5, QHeaderView::setResizeMode() is no longer available. Instead, you can use QHeaderView::setSectionResizeMode(): ui->tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); Or just call

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

爷,独闯天下 提交于 2019-11-28 19:43:33
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().screenGeometry(self).width() self.__sh = QtGui.QDesktopWidget().screenGeometry(self).height() self._

Qt Using Custom QItemDelegate for QTableView

痴心易碎 提交于 2019-11-28 17:17:43
问题 I followed the Spin Box Delegate tutorial, which Qt provides, to try to implement my own QItemDelegate . It would be used to specify a QComboBox to represent data in a QTableView cell but it is not working. My biggest problem is that I don't know when my QItemDelegate is going to be utilized. when itemModel->setData() is used or when itemModel->setItem() . I would suspect setItem() because I reimplemented a QItemDelegate (emphasis on the "Item") but the tutorial uses setData() and it works

paintEvent in QTableView derived class: Paint device returned engine == 0, type: 1

牧云@^-^@ 提交于 2019-11-28 14:15:21
As a follow up of Qt load indicator by animated image (aka preloader) or alternative? I try to paint inside a QTableView . But when I initialize the QPainter I get the following warnings. QWidget::paintEngine: Should no longer be called QPainter::begin: Paint device returned engine == 0, type: 1 Here is the code (SO answer, with a button it seems to work ): void CDerivedFromQTableView::paintEvent(QPaintEvent *event) { QTableView::paintEvent(event); // draw original content QPainter p(this); // Problem: QPainter::begin: Paint device returned engine == 0, type: 1 const QPixmap pm(QPixmap:

Qt QTableView how to have a checkbox only column

左心房为你撑大大i 提交于 2019-11-28 05:05:29
We are using a QTableView with Qt 4.6.3, and need a column that only has a checkbox in each cell. We're using a custom subclass of QAbstractTableModel as the model for the QTableView . Right now, we have a checkbox by setting the Qt::ItemIsUserCheckable flag. But we can't figure out how to get rid of the blank textbox next to the checkbox! How can we make the column only have a checkbox, nothing else? Here is a solution. For this to work properly, your column should not have the Qt::ItemIsEditable or Qt::ItemIsUserCheckable flags set. This reads the boolean values from Qt::DisplayRole and

PyQt QTableView prohibitively slow when scrolling with large data sets

余生长醉 提交于 2019-11-28 00:36:34
问题 I have a program that loads a profile from a csv file and displays the data in a table. The loading of a pandas data frame to the table is fast because I used a custom model implementation of QAbstractTableModel , but the resizing of the QTableView widget is incredibly slow. What can I do to make the resizing and scrolling smoother? 回答1: Well, I ended up modifying the custom table model I made to use numpy, and now it is blazing fast. Use this table model: import numpy as np class PandasModel

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()

Columns auto-resize to size of QTableView

末鹿安然 提交于 2019-11-27 11:10:36
问题 I am new to Qt and I have just managed to make a QTableView work with my model. It has fixed 3 columns. When I open a window, it look ok but when i resize the window, the QTableView itself gets resized but columns' width remains the same. Is there any build-in way to make it work? I want columns to resize to fit the edges of QTableView every the the window gets resized. 回答1: There is a header flag to ensure that the QTableView's last column fills up its parent if resized. You can set it like

Qt QTableView how to have a checkbox only column

≡放荡痞女 提交于 2019-11-27 05:26:24
问题 We are using a QTableView with Qt 4.6.3, and need a column that only has a checkbox in each cell. We're using a custom subclass of QAbstractTableModel as the model for the QTableView . Right now, we have a checkbox by setting the Qt::ItemIsUserCheckable flag. But we can't figure out how to get rid of the blank textbox next to the checkbox! How can we make the column only have a checkbox, nothing else? 回答1: Here is a solution. For this to work properly, your column should not have the Qt:

How to print a QTableView [closed]

女生的网名这么多〃 提交于 2019-11-26 23:32:12
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I have a Python and PySide app that connects to a mysql database and displays the results of a query in a QTableView. I need to print the contents of the table view. Here's some code: self.db_table = QtGui