Discussion:
QPen error when trying to subclass UserView
Michael Dzjaparidze
2014-10-17 16:37:40 UTC
Permalink
I'm trying to subclass UserView, but I get a:

ERROR: Qt: Usage of QPen is not allowed at this point!
ERROR: Primitive '_QPen_StrokeColor' failed.

for the following class code

MyViewSubClass : UserView {

*new { arg parent,bounds;
bounds = bounds ? (parent.notNil.if { parent.view.bounds } { nil } ? Rect(100,300,100,20));
^super.new(parent,bounds).init;
}

init {
this.drawFunc_(this.draw)
}

draw {

Pen.strokeColor_(Color.black);
Pen.moveTo((this.bounds.right - 10)@(this.bounds.height/2 + 5));
Pen.lineTo((this.bounds.right - 20)@(this.bounds.height/2 + 5))

}

}

GUI.current returns QtGUI for me. Is this yet to be implemented or am I doing something wrong here?
James Harkins
2014-10-18 01:40:45 UTC
Permalink
On October 18, 2014 12:37:57 AM Michael Dzjaparidze
Post by Michael Dzjaparidze
init {
this.drawFunc_(this.draw)
}
GUI.current returns QtGUI for me. Is this yet to be implemented or am I
doing something wrong here?
The thing that you assign to drawFunc should be a { function in braces }.
Because the draw call is not wrapped in a function, it executes immediately
during init. But this isn't in the context of refreshing the userview, so
you get the error.

hjh

Sent with AquaMail for Android
http://www.aqua-mail.com



_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
Michael Dzjaparidze
2014-10-18 08:22:34 UTC
Permalink
Oh man, completely missed that! Thanks for pointing it out.
Date: Sat, 18 Oct 2014 09:40:45 +0800
Subject: Re: [sc-users] QPen error when trying to subclass UserView
On October 18, 2014 12:37:57 AM Michael Dzjaparidze
Post by Michael Dzjaparidze
init {
this.drawFunc_(this.draw)
}
GUI.current returns QtGUI for me. Is this yet to be implemented or am I
doing something wrong here?
The thing that you assign to drawFunc should be a { function in braces }.
Because the draw call is not wrapped in a function, it executes immediately
during init. But this isn't in the context of refreshing the userview, so
you get the error.
hjh
Sent with AquaMail for Android
http://www.aqua-mail.com
_______________________________________________
sc-users mailing list
info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
Loading...