qtableview

How can I set the line style of a specific cell in a QTableView?

三世轮回 提交于 2019-12-07 12:33:35
问题 I am working with a QT GUI. I am implementing a simple hex edit control using a QTableView. My initial idea is to use a table with seventeen columns. Each row of the table will have 16 hex bytes and then an ASCII representation of that data in the seventeenth column. Ideally, I would like to edit/set the style of the seventeenth column to have no lines on the top and bottom of each cell to give the text a free flowing appearance. What is the best way to approach this using the QTableView? 回答1

How to update QAbstractTableModel and QTableView after sorting the data source?

拈花ヽ惹草 提交于 2019-12-07 07:05:32
问题 I have a custom data structure that I want to display in a PyQt application using a QTableView. I'm using a subclass of QAbstractTableModel to communicate with the data. The data structure itself is in a separate module and knows nothing about PyQt. Displaying and editing the data with the QTableView works, but now I'd like to sort the data and then update the model and view. After reading the Qt documentation for QAbstractTableModel and its ancestor QAbstractItemModel, my first approach was

Qt QTableView draw border around active cells

妖精的绣舞 提交于 2019-12-07 03:22:38
问题 I'm trying to implement behavior similar Excel in a QTableView, where a border is painted around the entire current selection. I have tried this what feels like a hundred different ways and keep getting problems. I can draw the border easily enough, but remnants of the border are left whenever the selection changes. Here is one example I've tried in QTableView::paintEvent ... void MyTableView::paintEvent(QPaintEvent* event) { // call QTableView's paint event first so we can draw over it

how do i get a checkbox item from a QTableView and QStandardItemModel alone?

北慕城南 提交于 2019-12-06 15:40:15
Seems using model.setData(index, Qt::Checked,Qt::CheckStateRole) is not enough to get the checkbox working right. Any suggestions? I believe you would need to subclass QStandardItemModel; override flags method and return Qt::ItemIsUserCheckable along with other flags for the column with check boxes. Below is an example: class TableModel : public QStandardItemModel { public: TableModel(); virtual Qt::ItemFlags flags ( const QModelIndex & index ) const; }; TableModel::TableModel() { //??? } Qt::ItemFlags TableModel::flags ( const QModelIndex & index ) const { Qt::ItemFlags result =

QFileDialog as editor for TableView: how to get result?

泄露秘密 提交于 2019-12-06 15:21:08
I'm using a QFileDialog as the editor for some columns in a QTableView . This basically works (modulo some focus issues, see here ): class DirectorySelectionDelegate(QStyledItemDelegate): def createEditor(self, parent, option, index): editor = QFileDialog(parent) editor.setFileMode(QFileDialog.Directory) editor.setModal(True) return editor def setEditorData(self, editor, index): val = index.model().data(index, Qt.DisplayRole) fs = val.rsplit(os.path.sep, 1) if len(fs) == 2: bdir, vdir = fs else: bdir = "." vdir = fs[0] editor.setDirectory(bdir) editor.selectFile(vdir) def setModelData(self,

How to filter Multiple column in Qtableview?

放肆的年华 提交于 2019-12-06 07:12:32
问题 I'm using QtableView to show my logs and to filter them by column, QSortFilterProxyModel is used. If i filter one column using certain value, and with the filtered data, if i try to filter second column, last filter gets reset and data are displayed corresponding to filter on second column. I want to achieve multiple column filter on Qtableview. Code snippet: self.tableView = QTableView() self.model = QtGui.QStandardItemModel(self) self.proxy = QtGui.QSortFilterProxyModel(self) self.proxy

How can I set the line style of a specific cell in a QTableView?

落爺英雄遲暮 提交于 2019-12-06 04:14:32
I am working with a QT GUI. I am implementing a simple hex edit control using a QTableView. My initial idea is to use a table with seventeen columns. Each row of the table will have 16 hex bytes and then an ASCII representation of that data in the seventeenth column. Ideally, I would like to edit/set the style of the seventeenth column to have no lines on the top and bottom of each cell to give the text a free flowing appearance. What is the best way to approach this using the QTableView? I could think about a couple of ways of doing what you need; both would include drawing custom grid as it

How to sort a QTableWidget with my own code?

[亡魂溺海] 提交于 2019-12-06 01:29:57
问题 I am using Qt4.5.2 on Linux. I have a simple QTableWidget, in which a column displays dates in a human-friendly format. Unfortunately "human-friendly dates" are not easy to sort correctly. So, in the QTableWidget I keep a hidden column with the UNIX timestamp corresponding to that date. I am trying to make sure that, whenever a request to sort on the DATE column is issued, in reality the sort be done on the (invisible) TIMESTAMP column. I tried reimplementing sortByColumn (this is in Python)

How to update QAbstractTableModel and QTableView after sorting the data source?

孤者浪人 提交于 2019-12-05 16:50:00
I have a custom data structure that I want to display in a PyQt application using a QTableView. I'm using a subclass of QAbstractTableModel to communicate with the data. The data structure itself is in a separate module and knows nothing about PyQt. Displaying and editing the data with the QTableView works, but now I'd like to sort the data and then update the model and view. After reading the Qt documentation for QAbstractTableModel and its ancestor QAbstractItemModel, my first approach was to try this: class MyModel(QtCore.QAbstractTableModel): __init__(self, data_structure): super().__init_

QTableView Zoom In/Out

戏子无情 提交于 2019-12-05 07:54:40
I'm trying to create a QTableView that can be zoomed in and out like in Excel. A similar question was asked here: Zooming function on a QWidget However, I'm subclassing the QTableView in PyQt and not C so reimplementing the entire PaintEvent method is a bit evolved. The source code for that is a bit complex: https://qt.gitorious.org/qt/tiittane-qt/source/bdd4a9149789f60974603e1f7621d51378f0a108:src/gui/itemviews/qtableview.cpp#L1282 I'm looking to see if there are any other viable options to have a zoom able TableView. My first attempt was by setting the font size then realized each column and