[PyKDE] QScintilla and Qt4
david at boddie.org.uk
Thu Jul 7 01:36:43 BST 2005
On Wednesday 06 July 2005 20:04, Thomas Fjellstrom wrote:
> I haven't changed the drawingcode (in PlatQt.cpp) much at all. So just look
> in there for how QScintilla works.. Basically, It has a "Surface" object
> that gets instantiated in paintEvent, and the drawing happens in calls to
> other scintilla qt functions called from paintEvent. (mainly in
> ScintillaQt.cpp::paintEvent() and the Surface methods in PlatQt.cpp)
The QtCallTip::paintEvent() function appears to be OK in that the QPainter
paints onto the QtCallTip widget. However, ScintillaQt::paintEvent()
involves painting onto a QWidget using a Surface helper class:
sw -> Init(&painter,0);
sw -> SetUnicodeMode(isUnicodeMode);
sw -> Release();
If I understand it correctly, this won't work any more because the painting
is not occurring inside the paint event of the QWidget returned by
PWindow(wMain). You could paint onto a QPixmap instead, but you will still
have to paint onto a widget at some point, so I don't think that it will get
around the problem because you will still be doing that externally.
I hope someone will correct me if I'm wrong, but the solution I see is to
change QextScintillaBase to use a QWidget subclass in which you can
reimplement paintEvent() to do the painting currently in ScintillaQt, and
just call repaint() on this widget from ScintillaQt::paintEvent().
Alternatively, with a QWidget subclass like this, you might also be able to
simplify the event filter implemented in QextScintillaBase. The paintEvent()
implementation in this custom widget would call ScintillaQt::paintEvent()
directly, probably passing a QPainter rather than a QPaintEvent.
I'd need to read the code a bit more and get something working with Qt 3
before I could be sure it would work with Qt 4. There's probably a good
reason why the code is currently arranged the way it is.
More information about the PyQt