Cannot do (qnew "QColor")

15 views
Skip to first unread message

b0b

unread,
Feb 1, 2012, 12:38:17 AM2/1/12
to eql-...@googlegroups.com
I am using eql 11.11.7. 
(qnew "QColor(int,int,int)" 100 100 0), all give error:

[EQL:err] QNEW-INSTANCE "QColor(int,int,int)" (100 100 0)

Polos Ruetz

unread,
Feb 1, 2012, 4:37:02 AM2/1/12
to eql-...@googlegroups.com
2012/2/1, b0b <boba...@gmail.com>:

> (qnew "QColor(int,int,int)" 100 100 0), all give error:
> [EQL:err] QNEW-INSTANCE "QColor(int,int,int)" (100 100 0)

Yes, because QColor is a "primitive":
The primitive Qt types (this was a design decision) are all listed in
the EQL GUI, so if you run (qgui), you find them under "Qt /
Primitives".

So, you can't use "qnew" for the primitives. In the case of QColor,
you must use a string representation, e.g. "#FF0000" or "red". You
find all recognized color names here:
http://www.w3.org/TR/SVG/types.html#ColorKeywords

But you can also use all static QColor functions, so in your case, one
of "fromRgb", "fromHsv", "fromCmyk":

(qfun "QColor" "fromRgb(int,int,int)" 255 0 0)

Paul

b0b

unread,
Feb 1, 2012, 5:03:05 AM2/1/12
to eql-...@googlegroups.com
okay.. i got it.. thanks a lot !! 

EQL is one of the nicest things on the planet !

b0b

unread,
Feb 1, 2012, 8:14:11 AM2/1/12
to eql-...@googlegroups.com
But why doesn't this work:

(qfun "QString" "number(int)" 1)

Polos Ruetz

unread,
Feb 1, 2012, 10:04:53 AM2/1/12
to eql-...@googlegroups.com
2012/2/1, b0b <boba...@gmail.com>:

> But why doesn't this work:
> (qfun "QString" "number(int)" 1)

Good question. But there are already nice Lisp functions like:

(write-to-string 16 :base 16) ; gives "10"

Paul

b0b

unread,
Feb 2, 2012, 12:18:57 AM2/2/12
to eql-...@googlegroups.com
Sorry to disturb again, but this chunk doesnt work:

(setq view (qnew "QGraphicsView"))

#<QGraphicsView 0x4715698>


(setq trans (qnew "QTransform(qreal,qreal,qreal,qreal,qreal,qreal)" 1 0 0 1 0 10))

#<QTransform 0x12bfd50>


(qfun view "setTransform" trans)     ; Error: Detected access to an invalid or protected memory address.


(qfun view "setTransform(QTransform)" trans)
    ; Same Error

I am just calling the  public function "setTransform" of a QGraphicsWidget.

Polos Ruetz

unread,
Feb 2, 2012, 5:36:01 AM2/2/12
to eql-...@googlegroups.com
2012/2/2, b0b <boba...@gmail.com>:

> (qfun view "setTransform" trans) ; Error: Detected access to an invalid
> or protected memory address.

Thanks, you found a bug! (I like catching bugs.)

I already fixed it. Please get the new version from gitorious. The
only file that changed is "src/ecl_fun.cpp" (regarding this bug).

Paul

Polos Ruetz

unread,
Feb 2, 2012, 6:26:53 AM2/2/12
to eql-user
On 2 Feb, 06:18, b0b <bobat...@gmail.com> wrote:
> (qfun view "setTransform" trans)     ; Error: Detected access to an invalid
> or protected memory address.

BTW, the nice thing with ECL is that we can easily run EQL from a
debugger.
Unix:

$ gdb eql

(gdb) r x.lisp

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000000
0x023436ba in QTransform::operator= ()

So, it was a simple null pointer exception (because I simply forgot to
add handling for the QTransform meta type).

Paul
Reply all
Reply to author
Forward
0 new messages