qtableview

QTableView: dataChanged event clears cell being edited

梦想与她 提交于 2019-12-10 17:22:14
问题 Working with a QTableView and QAbstractTableModel - when the model emits a dataChanged event for the cell being edited, the string the user has typed in the cell (but not pressed enter to 'commit' the edit) is erased. Example : Click a cell, type '123', cell is still in edit mode waiting for more text, dataChanged is emitted and the '123' is erased, leaving an empty cell in edit mode. Does anyone know how to stop this behaviour, or how the model can detect when the cell is being edited to

HowTo make restoreState() and saveState() work correctlly to QTableView class?

断了今生、忘了曾经 提交于 2019-12-10 15:42:29
问题 First of all, I wanted to say, that my problem was already discuss here, on SO, and here it is. But the answers are not the good ones... So, here is the problem : I have a QTableView class, with a simple model , connected with tableView->setModel(model); method. For example, I have 4-5 columns. I started up my project application and made some changes with columns width. After I pressed Exit, my project app save state of the tableView->horizontalHeader()->saveState(); data with QSettings to

QWidget update events but no visual update

泪湿孤枕 提交于 2019-12-10 13:32:45
问题 Using Qt4.8 on a Mint Linux 12, I implemented a simple window containing a QTableView to show contents of a model. The model data is continually updated (log messages) and the dataChanged() signal is emitted on a regular basis (i.e. every 100ms). The problem I see is stuttering visual updates on the table. I installed an event filter on the window that counts updateRequest -type events, which should trigger a widget repaint (also on child widgets, i.e. the tableView ). These come in with an

How to insert and remove row from model linked to QTableView

余生颓废 提交于 2019-12-10 12:18:33
问题 The removeRows() works as intended by deleting the selected row. But there is a problem with insertRows() . By some reason the new items do not appear at the index-number selected. What causes this problem? from PyQt4.QtCore import * from PyQt4.QtGui import * import sys class Model(QAbstractTableModel): def __init__(self, parent=None, *args): QAbstractTableModel.__init__(self, parent, *args) self.items = ['Item_003','Item_000','Item_005','Item_004','Item_001'] self.numbers=[20,10,30,50,40]

How to erase a QGraphicsItem from QGraphicsView using QPushButton

旧城冷巷雨未停 提交于 2019-12-10 11:58:49
问题 I am building a major user interface but I am stuck on a problem and in order to shrink the problem I build a small working example that carries exactly the problem. After the user creates a new .db file using the icon and saving for example to Desktop it is possible to load images(only in .png format for now) in the QGraphicsView and cliking on the checkbox to enable from Right: Drag to Right:Select it is possible to draw boxes on the image. With a right click inside the drawn box we can

QTableView and horizontalHeader()->restoreState()

廉价感情. 提交于 2019-12-10 10:16:46
问题 I can't narrow down this bug, however I seem to have the following problem: saveState() of a horizontalHeader() restart app modify model so that it has one less column restoreState() Now, for some reason, the state of the headerview is totally messed up. I cannot show or hide any new columns, nor can I ever get a reasonable state back I know, this is not very descriptive but I'm hoping others have had this problem before. 回答1: For QMainWindow, the save/restoreState takes a version number.

QTableView column width

可紊 提交于 2019-12-10 03:51:01
问题 I'm struggling to set column width manually in a QTableView . Why doesn't this piece of code work? tabb = new QTableView; tabb->resizeColumnsToContents(); for (int col=0; col<20; col++) { tabb->setColumnWidth(col,80); } If I omit tabb->resizeColumnsToContents(); it still doesn't work. 回答1: You should set model first and after this you will be able to change ColumnWidth : tabb = new QTableView; tabb->setModel(someModel); for (int col=0; col<20; col++) { tabb->setColumnWidth(col,80); } 来源:

How to trigger the edit mode of an item in a QTableView?

这一生的挚爱 提交于 2019-12-10 03:34:33
问题 I'm using QTableView and QStandardItemModel now. In the QTableView, if you double-click a cell, this cell will get into edit mode and you can edit its content. Now I have a problem, I want to trigger the edit mode of an item by code (by command), what should I do? I cannot find proper function or slot in QTableView or QStandardItemModel. Do I need to emit any signal to get into edit mode? And which signal I should catch if I want to know when the editing is finish (user press "Enter" or click

QTableView: How can I get the data when user click on a particular cell using mouse

你说的曾经没有我的故事 提交于 2019-12-09 15:53:57
问题 Actually I am new to Qt and unable to match up QMouseEvent with QTableview please help in solving this issue. 回答1: Here is an example of how you can get a table cell's text when clicking on it. Suppose a QTableView defined in some MyClass class. You need to connect the clicked signal to your own MyClass::onTableClicked() slot, as shown below: connect(tableView, SIGNAL(clicked(const QModelIndex &)), this, SLOT(onTableClicked(const QModelIndex &))); Slot implementation: void MyClass:

QTableView sorting signal?

陌路散爱 提交于 2019-12-08 20:03:45
问题 I use QTableView + QStandardItemModel to show some data (data stored in some other data structure), and this table view is sortable . Since it is sortable, when sorting this model, I also need to sort the order of stored data. I try to implement a slot for the sorting signal, but I don't know what signal is emitted when clicking the header to start the sorting action. I tried the clicked signal, but it's only emitted for data row, not for the headerData. what should I do if I want to do