how to show cursor in a particular cell of QTableWidget in pyQt
-
I am using following PyQt code and The requirement the cursor should blink at the start of cell 0,1
import sys from PyQt4.QtCore import * from PyQt4.QtGui import * data = {'col1':['1','2','3'], 'col2':['4','5','6'], 'col3':['7','8','9']} class MyTable(QTableWidget): def __init__(self, data, *args): QTableWidget.__init__(self, *args) self.data = data self.setmydata() self.resizeColumnsToContents() self.resizeRowsToContents() self.setCursorPosition() def setmydata(self): horHeaders = [] for n, key in enumerate(sorted(self.data.keys())): horHeaders.append(key) for m, item in enumerate(self.data[key]): newitem = QWidget() self.setCellWidget(m, n, newitem) self.setHorizontalHeaderLabels(horHeaders) def setCursorPosition(self): wid = self.cellWidget(0,1) wid.setCursor(QCursor(Qt.WaitCursor)) wid.setFocus() The requirement is to blink the cursor at the start of cell 0,1. The lines in method setCursorPosition does not help me . Can some one help me with the solution
-
Can any one help me here
-
You're putting an empty widget here so there's no sense in putting a cursor there.
What's the goal of the widget ?
Again, it's seems a duplicate of your other thread.
-
This is my Example , Actually it QTextBrowser and the goal of the project is to when user does an action , the cursor should blink at start of Qtextbrower
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *data = {'col1':['1','2','3'], 'col2':['4','5','6'], 'col3':['7','8','9']}
class MyTable(QTableWidget): def __init__(self, data, *args): QTableWidget.__init__(self, *args) self.data = data self.setmydata() self.resizeColumnsToContents() self.resizeRowsToContents() self.setCursorPosition() def setmydata(self): horHeaders = [] for n, key in enumerate(sorted(self.data.keys())): horHeaders.append(key) for m, item in enumerate(self.data[key]): newitem = QTextBrowser() newitem.setText("text") self.setCellWidget(m, n, newitem) self.setHorizontalHeaderLabels(horHeaders) def setCursorPosition(self): wid = self.cellWidget(0,1) wid.setCursor(QCursor(Qt.WaitCursor)) wid.setFocus() The requirement is to blink the cursor at the start of cell 0,1. The lines in method setCursorPosition does not help me . Can some one help me with the solution
-
Again, why are you using QTextBrowser in a cell to show text data ?
If you want to use it as an editor, make a custom QStyledItemDelegate for that. Based on your code, there's no reason to use a cell widget.
-
You do realize that QTextBrowser is a read-only widget ?
-
We have edit that