Results 1 to 3 of 3

Thread: PyQt4, QTableView with QLineEdit as a QItemDelegate and selection

  1. #1
    Join Date
    Jan 2010
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default PyQt4, QTableView with QLineEdit as a QItemDelegate and selection

    Hi folks,

    I'm having a strange problem. I have a grid of QLineEdits, QSpinBoxs, and other controls in a QTableView (see attached image). When I first create the page, every QLineEdit and QSpinBox item is selected.

    Selected.jpg

    I have tried things like:

    Qt Code:
    1. def createEditor(self, parent, option, index):
    2. self.lineEdit = QLineEdit(parent)
    3. self.lineEdit.setValidator(QDoubleValidator(self.lineEdit))
    4. self.lineEdit.textChanged.connect(self.emitCommitData)
    5. self.lineEdit.setText(self.getValue().toString())
    6. self.lineEdit.setAlignment(Qt.AlignVCenter|Qt.AlignRight)
    7. self.lineEdit.selectAll()
    8. self.lineEdit.setSelection(0, 0)
    9. return self.lineEdit
    To copy to clipboard, switch view to plain text mode 

    and

    Qt Code:
    1. def createEditor(self, parent, option, index):
    2. self.lineEdit = QLineEdit(parent)
    3. self.lineEdit.setValidator(QDoubleValidator(self.lineEdit))
    4. self.lineEdit.textChanged.connect(self.emitCommitData)
    5. self.lineEdit.setText(self.getValue().toString())
    6. self.lineEdit.setAlignment(Qt.AlignVCenter|Qt.AlignRight)
    7. self.lineEdit.deselect()
    8. return self.lineEdit
    To copy to clipboard, switch view to plain text mode 

    to no avail. Also, I considered that it might be something in the QTableView, and have tried even deselecting the items in it too.

    If I switch away from the window (alt-tab) and come back, all the text is deselected.

    Can anybody point me in the right direction?

    Developing on Windows
    ActivePython 2.6.2.2
    Qt 4.5.1

    TIA
    Mike

  2. #2
    Join Date
    Apr 2006
    Posts
    7
    Thanked 4 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: PyQt4, QTableView with QLineEdit as a QItemDelegate and selection

    Hi Mike,

    I have the same issue with QT 4.7.3 for c++. Do you have a solution yet?

    Best Richard

  3. #3
    Join Date
    Dec 2010
    Location
    Israel
    Posts
    90
    Thanks
    59
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: PyQt4, QTableView with QLineEdit as a QItemDelegate and selection

    Could be related to this bug? I had the same problem with a QSpinBox.
    https://bugreports.qt.nokia.com//browse/QTBUG-17348

Similar Threads

  1. Replies: 2
    Last Post: 26th November 2009, 04:45
  2. QLineEdit persistent selection
    By elmo in forum Qt Programming
    Replies: 5
    Last Post: 5th September 2009, 13:15
  3. Replies: 5
    Last Post: 8th June 2009, 22:16
  4. QTableView row selection
    By davemar in forum Qt Programming
    Replies: 2
    Last Post: 5th December 2007, 14:39
  5. selection in QLineEdit
    By spigel in forum Qt Programming
    Replies: 10
    Last Post: 17th May 2007, 09:43

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.