<HTML>
<HEAD>
<TITLE>Re: [PyQt] Newbe - QGraphicsScreen and QGraphicsView interaction problem</TITLE>
</HEAD>
<BODY>
<BLOCKQUOTE><FONT SIZE="4"><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>You are creating a new text() object and not adding it to the scene so it is never drawn. You may want to create a single text item and pass it to the marker class as follows:<BR>
<BR>
from PyQt4 import *<BR>
from PyQt4.QtGui import*<BR>
from PyQt4.QtCore import *<BR>
import sys<BR>
<BR>
class text(QGraphicsTextItem):<BR>
def __init__(self):<BR>
QGraphicsTextItem.__init__(self)<BR>
self.setFlag(QGraphicsItem.ItemIsFocusable)<BR>
self.setFlag(QGraphicsItem.ItemIsSelectable)<BR>
self.setTextInteractionFlags(Qt.TextEditable)<BR>
self.setPlainText("0000")<BR>
self.setZValue(3.0)<BR>
<BR>
class marker(QGraphicsItem):<BR>
def __init__(self, text):<BR>
QGraphicsItem.__init__(self)<BR>
self.setFlag(QGraphicsItem.ItemIsFocusable)<BR>
self.setFlag(QGraphicsItem.ItemIsMovable)<BR>
self.text = text<BR>
<BR>
def boundingRect(self):<BR>
return QRectF(25.0,0.0,25.0,270.0)<BR>
<BR>
def paint(self, painter, option, widget):<BR>
ss = painter.drawRect(25.0,230.0,25.0,25.0)<BR>
tt = painter.drawLine(37.5,0.0,37.5,270.0)<BR>
<BR>
def mouseMoveEvent(self, mouseEvent):<BR>
pt = self.mapToScene(mouseEvent.pos()).x()<BR>
self.setPos(pt-37.5,0)<BR>
self.update()<BR>
<BR>
def mouseReleaseEvent(self,mouseEvent1):<BR>
dbl = self.text<BR>
dbl.setVisible(True)<BR>
dbl.setPlainText(str(mouseEvent1.pos().y()))<BR>
dbl.setFlag(QGraphicsItem.ItemIsFocusable)<BR>
dbl.update()<BR>
self.scene().update()<BR>
<BR>
class MainScene(QGraphicsScene):<BR>
def __init__(self):<BR>
QGraphicsScene.__init__(self)<BR>
self.setSceneRect(0.0,0.0,480,270)<BR>
t = text()<BR>
item = marker(t)<BR>
self.addItem(t)<BR>
self.addItem(item)<BR>
<BR>
class AllItemsView(QGraphicsView):<BR>
def __init__(self):<BR>
QGraphicsView.__init__(self)<BR>
self.setWindowTitle("Text")<BR>
self.setInteractive(True)<BR>
self.setEnabled(True)<BR>
self.scene = MainScene()<BR>
self.mainScene = MainScene()<BR>
self.setScene(self.mainScene)<BR>
<BR>
if __name__=="__main__":<BR>
app = QApplication(sys.argv)<BR>
view = AllItemsView()<BR>
view.show()<BR>
sys.exit(app.exec_())<BR>
</SPAN></FONT></FONT></BLOCKQUOTE>
</BODY>
</HTML>