go-qml ubuntu touch'ish desktop app skeleton

115 views
Skip to first unread message

David Marceau

unread,
Apr 3, 2014, 3:49:39 PM4/3/14
to go-...@googlegroups.com
For your perusal,

http://adequatech.ca/goqmlsnowloadcount.tar.xz

Essentially and merged a bit of customtype and qmlscene examples
together to make this happen.

The trick was to load two .qml files for me. One was for the ubuntu
touch mainview and the tabs. The other was the custom type necessary to
set/get from.

Note: the actual custom type is non-gui'ish so you can actually see it
getting set before the actual window is shown on the desktop. It gives
confidence that golang-originating variables do get initialized before
windows get displayed because you're probably going to want to fill the
qml gui from the golang backend in the first place.

Cheers,
David Marceau


David Marceau

unread,
Apr 3, 2014, 4:48:19 PM4/3/14
to go-...@googlegroups.com
I spoke too soon. No matter what I try within the gui main view in the
button callback, it doesn't seem to know about gotype or my_go_text.

error:
file:///home/loongson/goqmlstuff/src/gopkg.in/v0/qml/examples/customtype/goqmlsnowloadcount/snowloadcount.qml:35
Expected token `,'
happens when I use
gotype.my_go_text: "happy222"
or
GoType { my_go_text: "Happy222" }

Any suggestions?

Button {
objectName: "helloTab_button1"
text: i18n.tr("clickme1")
anchors.horizontalCenter: parent.horizontalCenter
onClicked: {
console.log("clicked hello1...")
my_go_text: "happy222"
//gotype.my_go_text: "happy222"
//GoType { my_go_text: "Happy222" }
// my_go_int: 222
// my_go_int64: 222
// my_go_float64: 22.22
// my_go_bool: true
// my_go_string: "Hello222 GoType"
// my_go_color: Qt.rgba(0.2, 0.2, 0, 2)
// }
}
}

David Marceau

unread,
Apr 3, 2014, 8:46:24 PM4/3/14
to go-...@googlegroups.com
I got rid of the extra qml file with the different GoType values being
set and moved the setting within the MainView.

I have a problem. I want to access that variable from within the button
click callback, but I seem to have a scope access problem.
No matter what I try, I can't seem to get the qml to load up without errors.
error:
file:///home/loongson/goqmlstuff/src/gopkg.in/v0/qml/examples/customtype/goqmlsnowloadcount/snowloadcount.qml:44
Expected token `,'

Any suggestions would be welcome.

Thanks in advance.

Cheers,
David Marceau


import QtQuick 2.0
import GoExtensions 1.0
import QtQuick.Window 2.0
import Ubuntu.Components 0.1

MainView {
objectName: "mainView"
applicationName: "com.ubuntu.developer.uticdmarceau2007.uqttabtest1"
width: Screen.width
height: Screen.height
//this works. I see these values get set on the golang side.
GoType {
my_go_text: "222"
my_go_int: 222
my_go_int64: 222
my_go_float64: 2.22
my_go_bool: true
my_go_string: "Hello 2"
my_go_color: Qt.rgba(0.2, 0.2, 0, 2)
}

Tabs {
id: tabs
Tab {
title: i18n.tr("Hello..")
page: Page {
Column {
anchors.centerIn: parent
Label {
objectName: "helloTab_label"
anchors.horizontalCenter: parent.horizontalCenter
text: i18n.tr("You can change the Tab from Page title above.")
}
TextField {
objectName: "helloTab_tf1"
text: i18n.tr("editme1")
anchors.horizontalCenter: parent.horizontalCenter
}
Button {
objectName: "helloTab_button1"
text: i18n.tr("clickme1")
anchors.horizontalCenter: parent.horizontalCenter
onClicked: {
console.log("clicked hello1...");
//Nothing with Gotype/GoType works here.
//GoType { my_go_text : "555", my_go_int : 555, my_go_int64 :
555, my_go_float64 : 5.55, my_go_bool : true, my_go_string : "555Hello",
my_go_color : Qt.rgba(0.5, 0.5, 0, 5) };
//Gotype.my_go_text = "blah"
//GoType.my_go_text: "happy222intheclick"

Gustavo Niemeyer

unread,
Apr 3, 2014, 9:13:30 PM4/3/14
to David Marceau, Go QML
Can you isolate just the one failing line?
> --
> You received this message because you are subscribed to the Google Groups "go-qml" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to go-qml+un...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--

gustavo @ http://niemeyer.net

David Marceau

unread,
Apr 3, 2014, 9:31:22 PM4/3/14
to go-...@googlegroups.com
On 04/03/2014 09:13 PM, Gustavo Niemeyer wrote:
> Can you isolate just the one failing line?

I have a section with the following commented lines in the button callback.
>> //Nothing with Gotype/GoType works here.
>> //GoType { my_go_text : "555", my_go_int
: 555, my_go_int64 :
>> 555, my_go_float64 : 5.55, my_go_bool : true, my_go_string : "555Hello",
>> my_go_color : Qt.rgba(0.5, 0.5, 0, 5) };
>> //Gotype.my_go_text = "blah"
>> //GoType.my_go_text: "happy222intheclick"
>> //gotype.my_go_text: "happy222"
>> //GoType { my_go_text: "Happy222" }
>> // my_go_int: 222
>> // my_go_int64: 222
>> // my_go_float64: 22.22
>> // my_go_bool: true
>> // my_go_string: "Hello222 GoType"
>> // my_go_color: Qt.rgba(0.2, 0.2, 0, 2)
>> // }


If I uncomment any of these individually, they give that above error I
mentioned.

David Marceau

unread,
Apr 3, 2014, 9:39:27 PM4/3/14
to go-...@googlegroups.com
I even tried to give the GoType an id in order to try to access it
across many scope levels into the button callback. That didn't work either.

GoType {
id: mygotype

onClicked: {
console.log("clicked hello1...");
mygotype.my_go_text: "idididi"

When I run goqmlsnowloadcount against the above changes, I still get the
same error at the same location.

error:
file:///home/loongson/goqmlstuff/src/gopkg.in/v0/qml/examples/customtype/goqmlsnowloadcount/snowloadcount.qml:45
Expected token `,'

Gustavo Niemeyer

unread,
Apr 3, 2014, 9:55:53 PM4/3/14
to David Marceau, Go QML
Uncommenting any of these lines where they sit at the moment indeed
would create an invalid QML file. The value of onClicked is an
expression to be evaluated when the given signal is emitted. If you
want to create a new value from within such an expression, you can
make the Go constructor available to QML as part of a singleton, for
example, or you might also create the original GoType QML type you
registered dynamically.

Some documentation to help with these topics:

http://qt-project.org/doc/qt-5/qtqml-syntax-objectattributes.html#signal-handler-attributes
http://qt-project.org/doc/qt-5.0/qtqml/qtqml-javascript-dynamicobjectcreation.html

David Marceau

unread,
Apr 3, 2014, 11:54:07 PM4/3/14
to Gustavo Niemeyer, Go QML
On 04/03/2014 09:55 PM, Gustavo Niemeyer wrote:
> Uncommenting any of these lines where they sit at the moment indeed
> would create an invalid QML file. The value of onClicked is an
> expression to be evaluated when the given signal is emitted. If you
> want to create a new value from within such an expression, you can
> make the Go constructor available to QML as part of a singleton, for
> example, or you might also create the original GoType QML type you
> registered dynamically.
>
> Some documentation to help with these topics:
>
> http://qt-project.org/doc/qt-5/qtqml-syntax-objectattributes.html#signal-handler-attributes
> http://qt-project.org/doc/qt-5.0/qtqml/qtqml-javascript-dynamicobjectcreation.html

WARNING: THIS IS A RANT

I'm starting to wonder, is go-qml programmer friendly? Is this a better
way than c++/qtandroid, c++/qt, or c++/gtk or golang/gtk?

I'll tell you right now I honestly think go-qml isn't fun to work with
on Ubuntu Desktop or Ubuntu Touch at present. I'm not getting done what
I want to do within a reasonable amount of time. It should have been
done by now.

The hold-up: go-qml examples are not as comprehensive as qt's toolkit
examples/demos(c++,java) or gtk's examples/demos(c++, perl, python,
ada). There is a video of gopher running on ubuntu touch, but there is
not one ubuntu touch example specifically provided within go-qml
examples. They are all desktop only.

With respect to c++/qtandroid, c++/qt, or c++/gtk or golang/gtk,
right now c++/gtk(gtkmm) and golang/gtk(go-gtk) are easier to use.
Golang/gtk is most fun to use. The reason: more examples to refer to
and it took me 3 days to get what I wanted done with it.
I'm still struggling with QML interaction with go and the mailing-list
replies are sometimes clear with provided example code and sometimes are
foggy with simple URL references to unclear api documentation. I am not
criticizing the awesome go-qml work and demo videos. I am saying go-qml
isn't as accessible to go-qml wannabe-users to use and go-qml's
popularity will only grow if more examples are provided.

I really don't want to ask questions on the mailing list as much as I
have to get stuff done. I just want to grab some code examples
somewhere and get what I want done. I can do that in many other
languages and kits java/android/swing/awt, c++/gtk/qt/qtandroid/x/motif,
ada/tk/gtk/swing, python/tk/gtk, perl/tk, and golang/gtk. I just don't
know go-qml stuff and honestly qml-only samples don't apply since that
isn't the problem space I want to attack. I already have a qml-only gui
displaying an Ubuntu Touch-compliant wizard-like ui with 7 step-page
tabs. I know how to exchange variables and set variables with qml-only
across the tabs.
http://adequatech.ca/uqttabtest1.tar.bz2

The only curve-ball here is golang-specific and I don't have anything to
refer to easily. I'm doing my best to crack my head against go-qml api,
you can see that I did try and especially with:
http://adequatech.ca/goqmlsnowloadcount.tar.xz
which aims to connect the dots between customtype.go/qmlscene.go with
ubuntu touch mainview/tabs/buttons. I plan on using those golang
functionality specifics to fill up uqttabtest1 wizard gui.

I think what I am asking for is an example like customtype, but
custom-type is non-gui'ish. At the same time all the other examples
involves graphics drawing or opengl, which isn't my target either. How
about a reference point:
http://qt-project.org/doc/qt-4.8/dialogs-trivialwizard.html
http://learngtk.org/pygtk-tutorial/assistant.html
I would prefer something like the above qt/gtk wizard examples, but
showing the qml gui fields contents getting sent down to the golang
variables for further processing.


>
http://qt-project.org/doc/qt-5/qtqml-syntax-objectattributes.html#signal-handler-attributes
>
http://qt-project.org/doc/qt-5.0/qtqml/qtqml-javascript-dynamicobjectcreation.html
Giving me these two urls didn't cut it unfortunately.
It currently seems like a lot of work just to extract a value from qml
and send it down to golang for further processing in the backend. I
hope you can appreciate from my point of view that go-gtk has an
advantage at the moment. The gui was done in 3 days. The c++/qtandroid
one took a couple of weeks. The c++/gtkmm one was in-between: one week.
I am on week two with respect to effort into QML learning and actually
attempting go-qml golang bridging.

Thank you for letting me rant.

Cheers,
David Marceau

Gustavo Niemeyer

unread,
Apr 4, 2014, 11:11:47 AM4/4/14
to David Marceau, Go QML
On Fri, Apr 4, 2014 at 12:54 AM, David Marceau
<uticdmar...@gmail.com> wrote:
> WARNING: THIS IS A RANT

It doesn't feel like a rant. Seems just like good feedback about your
experience, which is welcome.

(...)
> The hold-up: go-qml examples are not as comprehensive as qt's toolkit
> examples/demos(c++,java) or gtk's examples/demos(c++, perl, python,
> ada). There is a video of gopher running on ubuntu touch, but there is
> not one ubuntu touch example specifically provided within go-qml
> examples. They are all desktop only.

Point taken. As we talked before, I do have to go back and work on the
phone again, as the platform is in development and people have been
fiddling significantly with it.

> With respect to c++/qtandroid, c++/qt, or c++/gtk or golang/gtk,
> right now c++/gtk(gtkmm) and golang/gtk(go-gtk) are easier to use.
> Golang/gtk is most fun to use. The reason: more examples to refer to
> and it took me 3 days to get what I wanted done with it.

I'm working on Go QML because I honestly think it's a more convenient
way to build graphic applications, and for my taste we lack good
alternatives in Go at the moment. With that said, this is not a fight.
If go-gtk or any other alternative suits your problem or understanding
better, you should feel free to use it. There's no need to keep
bringing a list of options up throughout the conversation.

> I'm still struggling with QML interaction with go and the mailing-list
> replies are sometimes clear with provided example code and sometimes are
> foggy with simple URL references to unclear api documentation. I am not
> criticizing the awesome go-qml work and demo videos. I am saying go-qml
> isn't as accessible to go-qml wannabe-users to use and go-qml's
> popularity will only grow if more examples are provided.

Agreed, we need more examples, and I've been adding new ones fairly
regularly. This is an area where contributions are also easy to
provide, and welcome. We should just keep examples simple and focused,
rather than big and convoluted.

(...)
> know go-qml stuff and honestly qml-only samples don't apply since that
> isn't the problem space I want to attack. I already have a qml-only gui
(...)
> The only curve-ball here is golang-specific and I don't have anything to

The QML language plays a relevant role on any application developed
with Go QML, so refusing to "attack that problem space" is simply not
an option. That internal conflict might explain part of the struggle
there. Note that the very thread we're discussing under is about
incorrect syntax in the QML file, which is completely unrelated to Go.

> I think what I am asking for is an example like customtype, but
> custom-type is non-gui'ish. At the same time all the other examples
> involves graphics drawing or opengl, which isn't my target either. How

I don't understand what you want here. There are two kinds of QML
types that may be registered via Go: those that paint, and those that
do not paint. We have examples for both: the customtype example does
not paint, the painting and the gopher examples paint. Those that
paint depend on OpenGL, and those that do not are of course not
GUI-ish. So what are you looking for?

Note as well that you don't have to register a type to be able to use
values from it from QML, unlike you implied in a response to Mark.
Method parameters, results, etc, will all just work without any
registration.

> about a reference point:
> http://qt-project.org/doc/qt-4.8/dialogs-trivialwizard.html
> http://learngtk.org/pygtk-tutorial/assistant.html
> I would prefer something like the above qt/gtk wizard examples, but
> showing the qml gui fields contents getting sent down to the golang
> variables for further processing.

Sorry, but we don't have a wizard or assistant for Go yet, and I don't
have the time to focus on that myself right now.

> http://qt-project.org/doc/qt-5/qtqml-syntax-objectattributes.html#signal-handler-attributes
> http://qt-project.org/doc/qt-5.0/qtqml/qtqml-javascript-dynamicobjectcreation.html
>
> Giving me these two urls didn't cut it unfortunately.
> It currently seems like a lot of work just to extract a value from qml
> and send it down to golang for further processing in the backend. I

Sending data from QML to Go is trivial, and there are multiple ways to
do it. For example, from customtype.qml:

text: "Happy " + GoSingleton.event + ", Go!"

from particle.qml:

onReleased: ctrl.textReleased(parent)

What takes a bit of time is when you want to understand how things
work, such as the basic syntax of QML. It doesn't make sense to
complain both that there's no documentation and then that reading the
documentation takes time.


gustavo @ http://niemeyer.net

David Marceau

unread,
Apr 4, 2014, 12:18:32 PM4/4/14
to Go QML
On 04/04/2014 11:11 AM, Gustavo Niemeyer wrote:
> On Fri, Apr 4, 2014 at 12:54 AM, David Marceau
> <uticdmar...@gmail.com> wrote:
>> WARNING: THIS IS A RANT
>
> It doesn't feel like a rant. Seems just like good feedback about your
> experience, which is welcome.
>
> (...)
>> The hold-up: go-qml examples are not as comprehensive as qt's toolkit
>> examples/demos(c++,java) or gtk's examples/demos(c++, perl, python,
>> ada). There is a video of gopher running on ubuntu touch, but there is
>> not one ubuntu touch example specifically provided within go-qml
>> examples. They are all desktop only.
>
> Point taken. As we talked before, I do have to go back and work on the
> phone again, as the platform is in development and people have been
> fiddling significantly with it.
>
>> With respect to c++/qtandroid, c++/qt, or c++/gtk or golang/gtk,
>> right now c++/gtk(gtkmm) and golang/gtk(go-gtk) are easier to use.
>> Golang/gtk is most fun to use. The reason: more examples to refer to
>> and it took me 3 days to get what I wanted done with it.
>
> I'm working on Go QML because I honestly think it's a more convenient
> way to build graphic applications, and for my taste we lack good
> alternatives in Go at the moment. With that said, this is not a fight.
Agreed this is far from a fight. It's me ranting about QML itself being
a limited vertical slice subset of the Qt C++ API horizontal breadth.
In all honesty, QML is still too immature for me. As a result, so is
go-qml.

> If go-gtk or any other alternative suits your problem or understanding
> better, you should feel free to use it. There's no need to keep
> bringing a list of options up throughout the conversation.
It's important to give a reference point from other toolkits when
discussing what the QML api lacks. Otherwise you won't have a clear idea
where I am going with this. I really don't want you to waste any effort
implying what I am wishing for when there is a clear example in some
other toolkit using another language that can clearly be used as an
inspiration.

>> I'm still struggling with QML interaction with go and the mailing-list
>> replies are sometimes clear with provided example code and sometimes are
>> foggy with simple URL references to unclear api documentation. I am not
>> criticizing the awesome go-qml work and demo videos. I am saying go-qml
>> isn't as accessible to go-qml wannabe-users to use and go-qml's
>> popularity will only grow if more examples are provided.
>
> Agreed, we need more examples, and I've been adding new ones fairly
> regularly. This is an area where contributions are also easy to
> provide, and welcome. We should just keep examples simple and focused,
> rather than big and convoluted.
>
> (...)
>> know go-qml stuff and honestly qml-only samples don't apply since that
>> isn't the problem space I want to attack. I already have a qml-only gui
> (...)
>> The only curve-ball here is golang-specific and I don't have anything to
>
> The QML language plays a relevant role on any application developed
> with Go QML, so refusing to "attack that problem space" is simply not
> an option. That internal conflict might explain part of the struggle
> there. Note that the very thread we're discussing under is about
> incorrect syntax in the QML file, which is completely unrelated to Go.
This is where I disagree. QML itself is certainly not intuitive and
the fact that I simply can't set a golang registered variable within a
button callback as I do gtk or c++ or java certainly substantiates that
fact. I am not impressed with having to work around that by passing the
parent object to a golang function in order to make that happen.
It doesn't feel right and it seems like a huge workaround to comply with
QML. MORE LINES OF CODE.

>> I think what I am asking for is an example like customtype, but
>> custom-type is non-gui'ish. At the same time all the other examples
>> involves graphics drawing or opengl, which isn't my target either. How
>
> I don't understand what you want here. There are two kinds of QML
> types that may be registered via Go: those that paint, and those that
> do not paint. We have examples for both: the customtype example does
> not paint, the painting and the gopher examples paint. Those that
> paint depend on OpenGL, and those that do not are of course not
> GUI-ish. So what are you looking for?
Ok. Here is what I am looking for(my example request):
-a simple Ubuntu Touch Mainview with a two fields: textfield and a
button. When you click the button, you send the textfield.text to a
golang Gotype.Text.
-That's not just non-gui like customtype, but it resembles it.
-That's not opengl, particle, painting at all because I am just using
the default 2d painting window stuff.
-That's not just qmlscene.go, but it does resemble it because my
attached needs it in order to do the necessary pre-qml housekeeping in
the qml engine, load up the qml file, and do the finalizing housekeeping
in the qml engine when closing.

> Note as well that you don't have to register a type to be able to use
> values from it from QML, unlike you implied in a response to Mark.
> Method parameters, results, etc, will all just work without any
> registration.
>
>> about a reference point:
>> http://qt-project.org/doc/qt-4.8/dialogs-trivialwizard.html
>> http://learngtk.org/pygtk-tutorial/assistant.html
>> I would prefer something like the above qt/gtk wizard examples, but
>> showing the qml gui fields contents getting sent down to the golang
>> variables for further processing.
>
> Sorry, but we don't have a wizard or assistant for Go yet, and I don't
> have the time to focus on that myself right now.
>
>>
http://qt-project.org/doc/qt-5/qtqml-syntax-objectattributes.html#signal-handler-attributes
>>
http://qt-project.org/doc/qt-5.0/qtqml/qtqml-javascript-dynamicobjectcreation.html
>>
>> Giving me these two urls didn't cut it unfortunately.
>> It currently seems like a lot of work just to extract a value from qml
>> and send it down to golang for further processing in the backend. I
>
> Sending data from QML to Go is trivial, and there are multiple ways to
> do it. For example, from customtype.qml:
>
> text: "Happy " + GoSingleton.event + ", Go!"
As you observed in my button callback, that is clearly not the case and
it gave an error as you know.

>
> from particle.qml:
>
> onReleased: ctrl.textReleased(parent)
As mentioned above, sending the parent object to a golang callback isn't
exactly what I was looking for either. I will try it.

> What takes a bit of time is when you want to understand how things
> work, such as the basic syntax of QML. It doesn't make sense to
> complain both that there's no documentation and then that reading the
> documentation takes time.
I am not gifted enough to quickly maintain/grasp golang bindings such as
yourself. I am trying to solve subject matter problem space on my own
free time. I am trying to distinguish go-qml from other languages and
their gui bindings.

If I take roughly 3 weeks of skimming over QML/go-qml and reflecting
over it and it's still foggy, then a rant is perhaps not such a bad idea
when you thought a task with it would take 2 days. The subtlety is
there and the popularity of QML and go-qml won't grow until those
subtleties are dealt with.

My first impression with the gopher demo was WOW! The loadup time was
almost instantaneous. The QML files being loaded happen quickly enough.
qt/c++ and gtk/c++ are both instantaneous, but they suffer from a longer
compile time. If go-qml gets it right, it will seriously reduce the
build cycle. That's why I am placing more consideration on go-qml and
ranting about all this.


Reply all
Reply to author
Forward
0 new messages