Hi
Sorry for the silly question if its, but I am really new to Qt Programming,
Below I am attaching a code in which I am drawing text using drawtext giving x and y co-ordinates for the Qpainter to paint, since these co-ordinates are taken from some other file in which the x and y values may be +ve or -ve, if negative values comes then its out of focus so I used some offset to transform (temporary one) as co-ordinates changes for different file it works fine but overwrites.
At present problem that I am facing is the distance between 2 text co-ordinates is small like 6pixels which overwrites on each other, how can I scale up co-ordinates depending on the widget area or is it there a way where I can look for bounding condition of the each text. There are other issues that text length may vary extra.
If someone give the guild lines as how to go about it, that would be great.
As this will be later done in graphicsscene because there will be mouseevent for each text item etc, at present I am not sure as how thing work around graphicsscene so testing in QPainter.
Qt Code:
def __init__(self,parent=None): self.setGeometry(100,100,500,500) self.setWindowTitle("Draw Text") def paintEvent(self,event): paint.begin(self) pos_transform = QtGui.QTransform() pos_transform.translate(600, 500) paint.setTransform(pos_transform) paint.drawText(-525,-470,"1st line") paint.drawText(-519,-464,"Second line is longer") paint.drawText(-508,-475,"3rd line") paint.end() dt = DrawText() dt.show() app.exec_()To copy to clipboard, switch view to plain text mode
Bookmarks