Does Qt need a modern C++ GUI API?
-
bq. For trivial apps with small number of custom elements, QML is an ease, but this changes as the number of custom elements increases, to the point QML becomes a burden.
Is this just an assertion or can you prove this? We use QML here in a desktop application with a number of plugins and we have not the impression that it scales bad. So it would be great if you could bring some facts to prove your statement.
-
What do you mean by "scales bad"? I am not talking about performance here, I am talking about functional code to glue code ratio, and that after a certain point the ease of QML is totally displaced by the tediousness of interfacing and gluing stuff together. How many custom elements that do custom painting do you have in your application? How much native functionality are you interfacing to QML? What do you mean by facts? Prove my statement? Is this an investigation or it is just you lacking common sense? There is a full hour dev talk on C++/QML integration, and it is just covering the basics, now imagine doing this over and over and over again, imagine projects where custom elements are 90% and more of your code, you still don't see how the limitations of QML and the workarounds around those can become a burden?
-
bq. QML is totally displaced by the tediousness of interfacing and gluing stuff together
Can you prove this or do you think repeating something often can substitute a proof. Ok, if proofes are overvalued here, then I simply claim you are wrong :O).
bq. How many custom elements that do custom painting do you have in your application
Because desktop components are not available yet, all components are custom.
bq. now imagine doing this over and over and over again, imagine projects where custom elements are 90% and more of your code, you still don’t see how the limitations of QML and the workarounds around those can become a burden
I don't need to imagine something because we already use QML here - and obviously you don't use QML because you simply state plain wrong things and from all you say here it becomes clear that you never used QML and therefore you have absolutey now idea what you are talking about - that's quite funny.
bq. Is this an investigation or it is just you lacking common sense
I simply asked you for a prove of your statement and you answered with an offense - nothing more to say :O)
-
@Uwe - "all" may sound like a lot, unless the total number of elements in your app is like 5, which could very well be the case, since you avoided sharing a concrete number in favor of "all". And then again, stuff like desktop components i.e. push buttons, scroll bars, check boxes and so on - you can entirely do in QML, there is no complexity, no advanced painting, no extensive logic involved in such components and there is no necessity for those to be C++ components. You don't even say what kind of application you are developing, how complex is it, the amount of business logic it contains relative to UI code. It sounds like it is you who fails to substantiate his claim, for it doesn't sound like your application can even fit in the profile of apps, the development of which renders QML a burned rather than an advantage.. And in case you failed to extract a PROOF from my well known facts, from my last post and from the dozens that preceded, then chances are do you lack common sense, it's just like a religious person asking for evidence god doesn't exist ;)
-
bq. It sounds like it is you who fails to substantiate his claim
I claimed nothing, i wrote:
bq. ...and we have not the impression that it scales bad
that is simply a subjective impression we got from using QML in our application.
bq. And in case you failed to extract a PROOF from my well known facts..
I did not found any facts in your posts - only assumptions or repetition of something you read somewhere.
bq. For trivial apps with small number of custom elements, QML is an ease, but this changes as the number of custom elements increases, to the point QML becomes a burden.
I simply do not understand how you can claim something like this.
How big is your application?
How many QML elements do you use?
Which concrete problems arised when you used a great number of custom QML elements?If you make a desktop application, you need to choose the right tool and need to do the right desicions. For some things in an application QWidgets are much better suited than QML Components and for other parts of the application QML components are better suited. We mixed both in our application - like QtCreator does it.
So simply claiming something does not mean that it is the truth.
-
bq. So simply claiming something does not mean that it is the truth.
To me this sounds like it applies to your earlier statement:
bq. We use QML here in a desktop application with a number of plugins and we have not the impression that it scales bad.
Where is the substantiation of that claim? Oh, but it isn't a claim, just a subjective impression, well in that case lets call my "claim" simply an objective impression.
You didn't provide any the specifics I noted you'd need to provide to actually be able to tell whether you have a point or not. Cuz right now you sound like you haven't done a lot of C++ components for QML. In short, like someone, who is clueless to the issue at hand.
Watch this talk, and try to imagine what would be if you need to make those considerations and add that glue throughout 90% of the development process.
http://qt-project.org/videos/watch/programming-with-qt-quick-6-6-c-integrationIt is no brainer really, QML is good when you already have the components, to just quickly and easily stitch them together into a working app. I have yet to see a QML application that actually does something beside being a front end for web services or tech demonstration. QML is perfect for such case scenarios, however a productivity oriented application with scores of custom components and performance critical logic is a completely different matter. And believe it or not, some people are after that kind of applications, so I assume you will not really get the point until you try and do it for yourself. Until then, I stand by my previous claim that you just happen to be clueless on that subject, not because you are stupid or anything, simply because you haven't been in that situation, you haven't experienced it, so you couldn't possibly know.
Now either prove me wrong by tossing an amazingly powerful and productive QML application in my face, or finally realize some people have higher requirements and standards, and that just because QML happens to work fine for your "mysterious application" doesn't mean it works for serious projects.
-
bq. well in that case lets call my “claim” simply an objective impression.
Finally you got it - hurray. That is the thing I try to say the whole time. The people that read your posts should know, that this is all your impression and that all you say about QML is not based on facts but that it is only your personal opinion.
bq. and that just because QML happens to work fine for your “mysterious application” doesn’t mean it works for serious projects.
And just because you don't get along with QML does not mean it does not work for serious projects ;-P
-
[quote author="Uwe Kindler" date="1336116905"]The people that read your posts should know, that this is all your impression and that all you say about QML is not based on facts but that it is only your personal opinion.[/quote]
And all this time I assumed people realized every opinion in this thread is a personal one. Perhaps you assumed I speak the words of god or something like that? What part of my statements did ever hint at my posts not expressing my opinions? And sorry to break your awesome theory, but my personal opinion is based on facts. And FYI I get along with QML just fine, just in my line of work, the extra effort to get along with QML is arguably worth it. So please, at least have the courtesy of not speaking in my name stuff that is not really true. Just because QML doesn't address the needs of some developers doesn't mean they are too stupid to get it, you know... But apparently that is your fixed idea or people, having a problem with the limitations and overheads of using QML.
@Lukas Geyer - what the H are you talking about? Denial? Prejudice? Where???
Pardon me but but voice your personal opinions just as loudly, and accusing people of what you do yourself is called hypocrisy. What kind of proof do you mean? I tried developing serious applications with QML, I experienced the tediousness, associated with writing extensive amount of C++ components for QML, and that's all the proof I need to voice an opinion based on my experience. Or do you imply I am a liar or something? Why do QML supporters keep asking me to prove the obvious, and kind of proof exactly do you mean? Can you even answer, or is it just some desperate effort to make me appear as unable to support my arguments by not providing that "evidence" whatever that may be? And just to get you a taste of your own medicine, where is the proof of me being wrong??? Because you, a guy whose avatar is a suit with a Qt emblem on it says so?I never implied my opinion has more weight than that of anyone else, but the same thing cannot be said for some other individuals around here. What has weight is the collective opinion, and as this, as well as the other poll indicates, it seems the people, completely happy with QML are a minority. So if you are that much frustrated by my edgy individuality, at least show some respect to all those other people, who appear to be more or less on the same page as me!
-
bq. and as this, as well as the other poll indicates, it seems the people, completely happy with QML are a minority
It is absolutely clear that nobody is perfectly happy with QML at the moment because it simply misses some important things like desktop components, theming or QtQuick 2.0. So normally nobody would vote for the first item. So it is really astonishing for me that such a lot of people voted for the first item in this poll.
bq. ...but my personal opinion is based on facts
Ok, then you might puplish a link to these facts? I ask for facts because I'm seriously interested in these facts that prove that QML is not suited for normal "serious" applications and not because I want to argue.
It is god if people raise their concerns about QML here and it is good to discuss about these concerns. But in my opinion it is not OK to claim things like
bq. For trivial apps with small number of custom elements, QML is an ease, but this changes as the number of custom elements increases, to the point QML becomes a burden.
without proving anything. The next one claims that you are going blind and deaf and that you get crippled fingers if you use QML often ;O)
-
One example of something that is trivial with C++ Qt, but impossible with QML (It might be possible, but I have not found how to do it) is to use a variable number of widgets.
For example, suppose which fields to display is something the program decides at runtime, base on the user login etc. So the program comes up with a list of fields to put on the form. Using the C++ API one would do something like this (pseudocode in python) :
@for field_name in field_names_to_display:
layout.addRow( field_name, QLineEdit() )@And the layout would contain all the needed fields, be it 2 or 20 fields.
Now these kind of things are huge time savers in larger applications. I'd like to know if these kind
of things are possible in QML, and if possible without JavaScript. -
@Erik
In QML you would probably use a Repeater for that, see http://qt-project.org/doc/qt-4.8/qml-repeater.html
-
I've seen you've already taken the easy way out, but there are still some things that are worth beeing mentioned.
The SceneGraph is not an exclusive feature of QML, see QSG* classes. There is a hardware-accelerated painter interface, see QGL* classes. There is also a traditional QPainter interface to QML, see QQuickPaintedItem. QML can be easily extended with C++ code, see QQuickItem.
QML has got a canvas interface, which allows drawing of straight and curved lines, simple and complex shapes, graphs, and referenced graphic images. It can also add text, colors, shadows, gradients, and patterns, and do low level pixel operations, see Canvas item.
Images in QML can be supplied in any of the standard image formats supported by Qt, including bitmap formats such as PNG and JPEG, and vector graphics formats such as SVG. If you need to display animated images, use the AnimatedImage element. BorderImage provides automatically scaled raster images.
QML is at an advantage due to beeing an declarative, interpreted language (id est not beeing C++). An interpreted API has to maintain source code compatibility, whereas an native API has to additionally maintain binary compatibility, thus is usually less extensible, as there are binary contracts to be abode.
QObject, QObjectList, QStringList, QVariant, QVariantList, QVariantMap and QAbstractItemModel can be directly exported to QML without any additional glue code. qmlRegisterType() allows for registering custom types, which are then available in QML immediately. QML supports C++ inheritance hierarchies and can freely coerce between known, valid object types. The QtQuick engine takes advantage of the meta-object information already present for each object.
There already is an extensive list of professional, productivity-oriented applications created with QtQuick, see KDE, QtMediaHub, N9, mixd.tv, httvBOX, Ocean Blue, IP4.tv et al.
QML is a replacement to QtWidgets in the same way the Graphics View Framework is a replacement to QtWidgets. QtQuick stands for Qt User Interface Creation Kit, not Qt Application Creation Kit.
Nokia spent 150 million dollars to acquire Trolltech just to release the framework under the terms of the LGPL, so that everyone can use Qt for closed-source non-commercial and commercial applications for free. Since then, Qt has grown exponentially in number of features, users, applications, SDK downloads, full time developers and specialized companies. Although Qt beeing an Open Governance community project now, Nokia is still (by far) number one code contributor, main contributor of legal resources to define and protect the Qt trademark, licensing and Contributor License Agreement, main funder of Qt training courses and materials, the Qt Certification and Qt Ambassadors program and the Qt Project infrastructure, the Qt Contributors Summit, the Qt Developer Days and experimental activities around Qt5 such as the QtonPi, Qt5 for N9, Qt5 for PhoneGap or INdT.
Yes, we've still got a long way to go with QtQuick and QML and there is definitely room for improvement. Therefore we need a vivid discussion about the future development. But such a discussion is quite impossible as long as we have such a diverging perception and as long as most subsequent conclusions are based on it.
I do not presume to know what the majority of people thinks about QtQuick and QML, and you shouldn't do that either. Especially as based on a biased poll with insignificant participation [the Qt SDK is downloaded by millions of people, 130 have participated in "your" poll, 85 of them have voted in favor of an (additional) native API], which doesn't even allow for differentiation between a native API beeing a replacement or an additional, secondary option to QML. You must have missed that in the second poll you are referring to (which suffers from the same insignificant participation) two-thirds of the people have voted in favor of QML.
But what I do know is that a lot of the argumentation against QML is based on denial, prejudice and personal opinions. It would help me a lot if I would actually see all the excessive amount of glue code that is obviously somewhere, if I would see the huge performance impact of QML on our applications, if I would see all those, or at least one, applications that have been made quite impossible due the way QtQuick works and if I would see that perfect native C++98 API, which has all the advantages of QML without its disadvantages. Where is all this?
-
Lukas Geyer, you keep stating that we need to keep to fact-based arguing... so I'll keep this short:
Hardware Accelerated C++ GUI API with bindings does not require a JavaScript Interpreter, a Virtual Machine, or a brand new declarative language.
There, that's it. There is no fact-based argument to defeat that. Please try as it will be amusing to read. Now please stop with the same old tired push of "use the QtQuick back-end directly" (QSG* classes) HURRRR you troll. We can both agree that there's a reason QML exists: to serve as a front-end to drive the back-end that you're proposing we manually drive. If it's so easy, why was QML invented to drive it? We want a purely C++ front-end to drive the QtQuick back-end, get it?
-
I do. And if you would have followed the discussion you would have seen that I've never had a problem with people demanding it, but rather how the gave reasons; and you would know that I've explicitly mentioned that Qt should have a native QtQuick API.
But I do have a spot of bother with it, and it is to be feared that your are most probably not amused with it, as it is quite of a killer argument: it is practically impossible to express the requirements for such an API in C++98.
But I'm quite sure you bring an idea, a sketch, a paradigm or possibly even an early implementation of such an API with you, which supports at least automatically re-evaluable expressions, or bindings as you call it, which substantiates your demand and in further consequence disproves my assumption, don't you?
-
[quote author="d3fault" date="1336928933"]Hardware Accelerated C++ GUI API with bindings does not require a JavaScript Interpreter, a Virtual Machine, or a brand new declarative language.[/quote]
It does not theoretically "require" them, no. But then again, no computing task theoretically "requires" anything more high-level and productive than assembler code. And not even that, why not go one step further and design a new hardware chip for each computing task?
Yes, there would have been different possibilities for solving the task that QtQuick/QML tries to solve. The Qt developers made a design decision. They gave higher value to maximizing productivity for application developers/designers, than to making diehard "C++ for the sake of C++" purists happy. A good choice.
-
[quote author="jdavet" date="1336997353"]They gave higher value to maximizing productivity for application developers/designers, than to making diehard "C++ for the sake of C++" purists happy. A good choice.[/quote]
Wrong. They gave higher value to creating a NeW eXtreMe eXper1mentaL "Designer Friendly" AppLiCatiOn pr0gr4mming LaNguaGe in hopes that it would earn them more moneys in the mobile market. They're pissing a lot of us C++ devs off by forcing the use of this NEW BITCHIN PROGRAMMING LANGUAGE [if we want to use up-to-date UI]. We already know how to code and we don't need a javascript interpreter thank you very much.
If I was a C++ purist I'd be using Boost, not Qt. Qt's use of MOC makes C++ purists cringe.
[quote author="Lukas Geyer" date="1336990448"]But I do have a spot of bother with it, and it is to be feared that your are most probably not amused with it, as it is quite of a killer argument: it is practically impossible to express the requirements for such an API in C++98.[/quote]
I agree. A lot of the previous examples included the use of lambdas and C++11 features. Here is one that is C++98.... though it is uglier because of it. (best case scenario: support both)
What you type:
@m_SomeDeclaredView.somePropertyToBeUpdatedWhenTheBindingPropertiesChange = Q_BINDING((Q_BIND(m_SomeOtherObject.someProperty1) + Q_BIND(m_AnotherObject.someProperty2)) /Q_BIND(m_YetAnotherObject.someProperty3) + aConstantInteger);@Post-MOC result:
@
//Auto-Generated
autoGeneratedEvaluateFunction()
{
return (m_SomeOtherObject.someProperty1 + m_AnotherObject.someProperty2) / m_YetAnotherObject.someProperty3 + aConstantInteger;
}
connect(m_SomeOtherObject.someProperty1, SIGNAL(changed()), this, SLOT(autoGeneratedEvaluateFunction());
connect(m_AnotherObject.someProperty2, SIGNAL(changed()), this, SLOT(autoGeneratedEvaluateFunction());
connect(m_YetAnotherObject.someProperty3, SIGNAL(changed()), this, SLOT(autoGeneratedEvaluateFunction());//Your original binding, wherever you typed it
m_SomeDeclaredView.somePropertyToBeUpdatedWhenTheBindingPropertiesChange = autoGeneratedEvaluateFunction();@in the precompiler stage,
each Q_BIND evaluates it's contents to ensure it is being pointed to a proper Q_PROPERTY
each Q_BIND 'makes note of (somewhere)' the property it points to
the contents of Q_BINDING are stored in some "autoGeneratedEvaluateFunction" function, with the Q_BIND macros removed (since we've already processed them)
the right hand side of the equals sign points to autoGeneratedEvaluateFunction() to get the initial state
each of the Q_BIND'd properties we 'made note of' have a slot connected to their NOTIFY Q_PROPERTY signal. this connection is disconnected when the view is no longer seen.
the slot that the NOTIFY signals is the autoGeneratedEvaluateFunction function. there could also be some: if(new != old) { old = new; emit changed(); } protection in the property's setter.since aConstantInteger is not surrounded by Q_BIND (and since it's constant!), there are no signals/slots to set up. Q_BINDING might (idktbh) also need compiler optimization-prevention so it doesn't get rid of aConstantInteger
I pulled this example out of my ass. I'm sure others could come up with a better solution. Do you also need to be shown how to declare a GUI in C++?
[quote author="jdavet" date="1336997353"]It does not theoretically "require" them, no. But then again, no computing task theoretically "requires" anything more high-level and productive than assembler code. And not even that, why not go one step further and design a new hardware chip for each computing task?[/quote]
Any solution is not the best solution. Qt strives for the best solution. There are plenty of overly expensive languages that provide the exact same functionality as Qt... usually incurring a run-time cost (JIT etc) where Qt requires none. Java/.Net/any-interpretted-scripting-environment... are all inferior to Qt.... for the same reasons QML will be inferior to a Hardware Accelerated C++ GUI API with Bindings: Native and/or Not Interpretted. (give me QML compiled down to byte code in my executable and don't force the use (includes simple loading without using (a lot of people saying: don't like js? don't use it!)) of a JavaScript Interpreter/VM at runtime and I will consider it a 'good-enough' compromise sadface) -
Yes, using a preprocessor is a possibility.
But let's take a look at the idea behind: we are adding specific language extensions because the requested functionality is not supported, which are then translated by a seperate tool into native code.
If we now extend your example to the correct use of properties (which require the use of property() and setProperty(), as there is no such thing as a property in C++) or a more declarative way to describe a hierarchy of components using key-value assignment (as requested and suggested on the mailing list), basically everything on the list for an advanced GUI API (and everything that distincts QtQuick from the already existing, hardware-accelerated Graphics View API) we end up adding specific extensions and then, although having a native API, in creating and implementing our QtQuick components using those language extensions - a specific meta-programming language front-end - which is then translated into native back-end code by a seperate tool. What we implement in native code is the required supporting code, like constructors, destructors, operators, memory management and so forth.
If you bring this to a head, you'll end up exactly where we are right now. We have a specific meta-programming front-end language, QML, which is then translated by a seperate tool, the declarative engine, into a native representation (no, QML is not interpreted, it is translated into a native representation and no, V8 does not interpret JavaScript, beeing a just-in-time compiler it produces run-time optimized machine code, which is then executed). In both cases you will have to (learn and) use a specific front-end language (with different aesthetics) which is not C++.
You've already been told that a byte-code compiler for QML is possible, partially done and possibly integrated in Qt 5.1 if there is a strong momentum from the community.
-
Just food for thought....
Someone mentioned here the BlackBerry 10 Cascades framework based on Qt/QML as non toy app development, well, RIM seems to think that having a C++ alternative interface for Cascades as well (and not just QML only) is actually a good idea and looks like an implementation like that is very viable (as opposed as some people here seem to think), check this link for an example:
"BB10 developer documentation":https://developer.blackberry.com/cascades/documentation/getting_started/introtocascades.html
Also, a while ago I contributed to a declarative language and API that was very controversial as well called JavaFX with the very cool and infamous FX Script, well, if history has something to teach us, by version 2 they ended up adding a java interface for it because there were too many developers complaining that had to forcefully use FX Script instead of the language everyone knew. At the end, FX Script died, java interface prevaled, and even ended up adding an XML declarative interface (go figure) instead of FX Script.