Can't get QIcon::fromTheme to work

119 views
Skip to first unread message

thrall

unread,
Nov 14, 2012, 3:38:46 PM11/14/12
to eql-...@googlegroups.com
I can't seem to get an icon from a theme, possibly because I am not using it the right way. I have tried various ways, such as:
(qfun "QIcon" "fromTheme(QString)" "icon-name")
(let ((q-icon (qnew "QIcon")))
  (qfun q-icon "fromTheme(QString)" "icon-name"))
This results in:
[EQL:err] QINVOKE-METHOD #<QIcon 0x4e533c0> NIL "fromTheme(QString)" ("icon-name")
Detected access to an invalid or protected memory address.
   [Condition of type EXT:SEGMENTATION-VIOLATION]

The C++ code for what I want would be:
QIcon::fromTheme("icon-name");

What is the correct way to do this, and does it work?

Mark Cox

unread,
Nov 15, 2012, 12:09:14 AM11/15/12
to eql-...@googlegroups.com
G'day,
In Qt 4.8.3 the static method QIcon::fromTheme accepts two arguments, a QString and a QIcon. The way to invoke this method is:

(qlet ((tmp (qnew "QIcon")))
(qfun "QIcon" "fromTheme(QString,QIcon)" "mac" tmp))

Which results in:
NIL
T

Thanks
Mark

Polos Ruetz

unread,
Nov 15, 2012, 6:41:34 AM11/15/12
to eql-...@googlegroups.com
2012/11/14, thrall <taha...@gmail.com>:
> I can't seem to get an icon from a theme, possibly because I am not using
> it the right way. I have tried various ways, such as:
> (qfun "QIcon" "fromTheme(QString)" "icon-name")

sorry, this was a bug; it's fixed now. I tested with (Linux):

(qfun "QIcon" "fromTheme" "edit-undo")

Paul

thrall

unread,
Nov 15, 2012, 8:17:46 AM11/15/12
to eql-...@googlegroups.com
sorry, this was a bug; it's fixed now. I tested with (Linux):

(qfun "QIcon" "fromTheme" "edit-undo")

Paul

Excellent! It works now. Thanks.

Looking at the Qt documentation, I see that Mark is correct; it does have an optional QIcon argument to provide a fallback icon. It is much more convenient not to have to provide this argument if it isn't wanted though.

Regards,
Tom
Reply all
Reply to author
Forward
0 new messages