I have started learning qt today and have a question. When I create a project, it comes with *.ui file which is XML kind of file but in the book, I am only creating UI with pure c++(classes). I have heard there is another way of creating the UI with qml.
So, What are pros and cons of each UI creating way?
Thanks in advance
EDIT: I am using QT 5.1.0
Don't forget that you can also embed a QtWebkit view and use HTML directly as the user interface controls.
A lengthy answer with the specifics of each sub-framework could be provided, but the QT project people have already answered this question with a chart of their own:
http://qt-project.org/doc/qt-5.1/qtdoc/topics-ui.html#comparison
The .ui file is generated for/by "visual" design layout tools such as QtDesigner - I would not suggest you generate or edit them by hand; if you choose not to use "visual" or "RAD" GUI design tools then programmatically instantiating widgets in C++ is probably fine.
Related
Have a look at this figure below, which is a Quick Book Enterprise Solution 2014
Judging by its interface (not its DLL), I don't think you can easily guess with what platform/language does the above application was created. Qt? .NET? Java? It has its own border, custom menu, ... etc. In a simple wording, "it has totally customized UI that make it stand from the rest".
What do we need to be able to create this kind of application with fully customized UI? And what if I add cross platform aspect in this application? Different customized widgets in different OSes... but maintaining the same level of UI appearance...
I have previous experience with Qt, .. but I am not sure Qt can do this.. or is it?
For instance, you can write your own plugin similar to the existing qt style plugins.
Here, you can find an example how to write widget based style plugins with Qt 5:
QtWidgets 5.0: Style Plugin Example
You would work with the QStylePlugin plugin interface.
If you are looking into a bit more modern solution, you may find this qml style and theme support documentation useful.
I'm wondering how to develop visually modern, with attractive GUI applications in QT. When I run QT Creator and start new project, the GUI looks very basic and "pure", just like simple win32 apps. But look for example at Allegorithmic Substance Designer 2, where GUI looks somehow similar to WPF. There are many other applications with nice-looking GUI. So, the question is: how to do this? Is there any extension/library to QT, which provide richer GUI experience? Or it must be developed from scratch? Thanks for replies in advance.
As well as Nano's answer, I think it would be worth your while to search around for any Qt stylesheets others have made.
For example, this one that mimics Microsoft Office.
Unfortunately, there doesn't seem to be very many of them available.
I found these useful links, some of whose links may give some ideas:
Qt Stylesheet Snippet Repository
Another idea might be to search for example qml files in Google Code Search. This search for .qml files has plenty of hits. Before using any of them, you would obviously need to check its license.
Have you tried Nokia's Qt Creator? If you're looking for something "similar" to WPF I assume you're referring to its declarative nature, QML being XAML's counterpart in such regard.
I noticed in 2.1 of QTCreator, that they now have a sort of intellisense similar to that of Visual Studio. I know intellisense is Microsoft's name for this concept of the helpful tooltip that pops up giving you a description of the method, parameters etc so i don't know what this is actually called. Does anyone know how to add these type of pop-up comments to methods and classes in QT?
Again to clarify what i'm talking about are like javadoc comments or the "///" in C#. I'm hoping the devs of QT have a way for the users to make their own comments.
Thanks for the help,
Jec
I've been wanting to do this as well.
I found this thread over on qtCentre.org where someone has integrated their own docs into the QT Creator Tooltips. I haven't tested it myself, but it sounds reasonable:
http://www.qtcentre.org/archive/index.php/t-40324.html?s=98d48c38547da14b0725e5106d83c315
To use your own documentation in Qt
Assistant (and in Qt Creator help as
well) you need to create Qt Compressed
Help file (.qch
(http://doc.qt.nokia.com/4.7/assistant-custom-help-viewer.html#displaying-custom-documentation))
and register it in Assistant and
Creator. Doxygen has several tools
exactly for Qt. There are tags in it's
config file, that help you to create
the documentation exactly the way you
need. E.g. with GENERATE_QHP tag you
can make it create the ready qhp
(http://doc.qt.nokia.com/4.7/assistant-custom-help-viewer.html#creating-a-custom-help-collection-file)
(Qt Help Project) file (you need this
to generate the .qch). If you don't
need to edit this file manually before
creating the .qhc, you can set the
value of QHG_LOCATION tag to the
location of your qhelpgenerator.exe
(usually it's here (in Windows):
/mingw/bin/qhelpgenerator.exe)
and it will generate the ready
documentation. Register it in Qt
Assistant (optional) and Creator and
you're done. After this all your
documented types, functions, members,
etc. will have the tooltip with F1
button hint. And of course pushing F1
will show your documented help for it.
I am wondering which way is the best to start building a GUI+SOFT in Qt. I am trying to build a sound media player based on a MVC pattern. Until now i have found 3 ways to do so.
1- Should I use a .ui file thanks to Qt designer, is it flexible enough ?
2- Should I use QML to make the design than integrate it to a C++ development ?
3- Should I just start from scratch and do it by hand without Qt Designer and using Qt library ?
Thank you very much for your answers.
NOTE: I'm using PyQt, so my comment may not be the most relevant.
I found Qt Designer to be great to create UIs, but then, when comes the time to modify them later, it becomes somewhat of a problem. Inserting new elements in an existing layout is often tricky, and you have to break all your layouts and re-assemble them (hoping you didn't mess anything up). Moreover, if your app is not trivial, you'll likely end up with code "fixing" what the .ui can't do. There are other tricky cases like that, but I don't remember them right now.
I ended up getting rid of my .ui files. So what I'd recommend is to initially use the designer to create the UI, and then use only the generated code from that point forward.
If you want your UI to be animated and it is not a requirement to follow platform UI appearance, QML is by far the best way to achieve this. If you want a UI that appears like any other application on your system and has limited animation then stick with QtDesigner and standard widgets.
I prefer building UI completely from scratch. This gives a lot of flexibility and better understanding of what is where, but on the other hand changing layout sometimes is a big headache.
I would use Qt Designer, as this is the easiest method IMHO.
Is there a c++ framework for building rich desktop applications?
Essentially the important feature I'm looking for similar to Flex4 MXML to separate the visual presentation and application logic into xml. Does Qt4, for example, allow the visual appearance to be specified in xml definition? This is state based, so on events the UI changes and has new visual content like this and this
Yes.
Using Qt's Designer tool, you can separate the UI design into an XML, and then a UI compiler (uic tool) compiles it into a UI class.
Your code uses that class (either by delegation or by inheritance) to show its own GUI.
And throw in Qt's signal-slot mechanism for event handling and you have a heavenly development framework for C++ GUI apps :)
Edit:
Although Qt has a tool to specify UIs in XML, you don't always have to do so. You can create UIs programmatically, but why would anyone do so, right? The day I learnt to use Qt Designer was the day I stopped creating UIs programmatically.
And I personally feel that Qt's paradigm of separating the UI from the event handling code (unlike netbeans UI designer) is aaawwweeesssooommmeee.
Qt does. The XML is compiled into code at build time, so the UI remains static (i.e., you have to re-compile to change it).
Just FWIW, with wxWidgets and XRC you can specify a dynamic UI in XML -- i.e., the XML file remains separate from application and changing the XML file makes matching changes to the UI (within limits, of course).