You are not logged in.
I'm working on a Qt project and I have a QPushButton on which I'd like to allow word wrapping:
I know I can change it to a QLabel, but due to the specific purpose of the application, it needs to be clickable (so I think that means it must be a QPushButton). I've searched around online a bit and the only solution I've been able to find is "inheriting." However, I can't seem to figure out how to do it. Can anyone help? Thanks!
Last edited by tony5429 (2009-08-22 19:20:38)
Offline
I don't think that is possible, as it is against QPushButton's intended design.
However, you could easily derive a class from QLabel and overload the
virtual void QWidget::keyPressEvent ( QKeyEvent * event )
function or install an event filer (http://doc.trolltech.com/4.5/eventsandfilters.html)
on a "plain" QLabel to do the exactly same.
Offline
What about this... it is possible to put an image on a QPushButton, correct? Could I use the width of the QPushButton to create an SVG image of the text, with word-wrapping and add the SVG to the QPushButton?
Offline
In case anyone is interested, the SVG fix worked. The code is now implemented in vesion 1.1.2 of Yellowcot: http://yellowcot.org
Offline