cannot override QGraphicsView::drawBackground()

101 views
Skip to first unread message

b0b

unread,
Jan 31, 2012, 1:15:23 AM1/31/12
to eql-user
Hi,

I am trying to draw a grid in my graphing application. I need to draw
a grid which gets drawn according to the current view rect. It should
also be redrawn every time the view rect changes. I figured that it
should be best done by overriding the
" virtual void drawBackground ( QPainter * painter, const QRectF &
rect ) " function.

But that leads to an error:

[EQL:err] QOVERRIDE #<QGraphicsScene 0x1141818>
"drawBackground(QPainter*,const QRectF&)" #<bytecompiled-closure
#<bytecompiled-function 0233d488>>

from this simple code:

(in-package :eql)

(defun start ()
(let* ( (graphic (qnew "QGraphicsScene(QObject*)" nil))
(graphview (qnew "QGraphicsView(QGraphicsScene*,QWidget*)" graphic
nil))
)
(qoverride graphic "drawBackground(QPainter*,const QRectF&)" (lambda
(a b) (format t "hi") ))
(qfun graphview "show")
))

(start)

What is wrong with qoverride ?

Polos Ruetz

unread,
Jan 31, 2012, 5:12:50 AM1/31/12
to eql-...@googlegroups.com
2012/1/31, b0b <boba...@gmail.com>:

> [EQL:err] QOVERRIDE #<QGraphicsScene 0x1141818>
> "drawBackground(QPainter*,const QRectF&)" #<bytecompiled-closure
> #<bytecompiled-function 0233d488>>

Your sample code works perfectly for me (with Qt 4.7, I didn't try Qt 4.8).
Did you use a recent EQL version?
(In an earlier version, there was missing
"QMetaObject::normalizedSignature" in file "src/ecl_fun.cpp", in
function "cl_object qoverride(...)").

So, can you try to change:
(qoverride graphic "drawBackground(QPainter*,const QRectF&)..." to:
(qoverride graphic "drawBackground(QPainter*,QRectF)..."

Does the second one work?

Paul

b0b

unread,
Jan 31, 2012, 5:30:30 AM1/31/12
to eql-...@googlegroups.com


On Tuesday, 31 January 2012 15:42:50 UTC+5:30, Polos Ruetz wrote:
2012/1/31, b0b <boba...@gmail.com>:
> [EQL:err] QOVERRIDE #<QGraphicsScene 0x1141818>
> "drawBackground(QPainter*,const QRectF&)" #<bytecompiled-closure
> #<bytecompiled-function 0233d488>>

Your sample code works perfectly for me (with Qt 4.7, I didn't try Qt 4.8).
Did you use a recent EQL version?
(In an earlier version, there was missing
"QMetaObject::normalizedSignature" in file "src/ecl_fun.cpp", in
function "cl_object qoverride(...)").


My EQL versions are: 11.5.9, Qt: 4.7.2. I dont think that's recent.. I suppose getting the recent one would mean lots of building and stuff..


So, can you try to change:
    (qoverride graphic "drawBackground(QPainter*,const QRectF&)..." to:
    (qoverride graphic "drawBackground(QPainter*,QRectF)..."

Does the second one work?


Ya ! The second one works ! 
Can I do this substitution (const reference) to (by value) for any other function call override that I might have problems with ? 

Thanks for the quick solution.

Paul

Polos Ruetz

unread,
Jan 31, 2012, 5:56:43 AM1/31/12
to eql-...@googlegroups.com
2012/1/31, b0b <boba...@gmail.com>:

> Can I do this substitution (const reference) to (by value) for any other
> function call override that I might have problems with ?

Sure, just look at how the "qoverride" functions are shown in both
"qapropos" and doing directly "eql -qgui" (that is, in the EQL
documentation, all functions are shown in a simplified string
representation).

But you should consider to upgrade EQL eventually, because of the GC
bug discovered recently (see this list).

Paul

Reply all
Reply to author
Forward
0 new messages