[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: [PyQt] QGraphicsView, QTableView and a QComboBox Editor
From: Aron Bierbaum <aronbierbaum () gmail ! com>
Date: 2009-07-27 18:24:45
Message-ID: 34457a4c0907271124u5f63da97o561a4573a05abb59 () mail ! gmail ! com
[Download RAW message or body]
We are running into a few issues with item views and QGraphicsView. We
have a custom delegate that displays a combo box with valid values.
The issue we are seeing is that this works great when using the basic
QTableView. But as soon as we add the view to a QGraphicsProxyWidget
so that we can place it in a QGraphicsScene, the combo box no longer
appears when editing. Does anyone have any ideas how to work around
this, or do you know if this is a known issue? I have attached a
simple example showing the issue.
Thanks,
Aron
["list_view_test.py" (text/plain)]
import sys
from PyQt4 import QtCore, QtGui
class ListModel(QtCore.QAbstractListModel):
def __init__(self, parent = None):
QtCore.QAbstractListModel.__init__(self, parent)
self._values = [True, False, True, False]
def rowCount(self, parentIdx):
return len(self._values)
def flags(self, index):
"""
Returns the item flags for the given \p index.
"""
if not index.isValid():
return QtCore.Qt.ItemIsEnabled
return QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEditable
def data(self, index, role = QtCore.Qt.DisplayRole):
if not index.isValid():
if role == QtCore.Qt.UserRole:
return None
else:
return QtCore.QVariant()
value = self._values[index.row()]
if QtCore.Qt.UserRole == role:
return values
elif role == QtCore.Qt.DisplayRole or role == QtCore.Qt.EditRole:
return QtCore.QVariant(value)
return QtCore.QVariant()
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
list_view1 = QtGui.QListView()
model1 = ListModel()
list_view1.setModel(model1)
list_view1.setWindowTitle("Working")
list_view1.show()
list_view2 = QtGui.QListView()
model2 = ListModel()
list_view2.setModel(model2)
scene = QtGui.QGraphicsScene()
proxy = scene.addWidget(list_view2)
graphics_view = QtGui.QGraphicsView(scene)
graphics_view.setWindowTitle("Not Working")
graphics_view.show()
app.exec_()
_______________________________________________
PyQt mailing list PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic