November 2, 2011

ephe ephe
Lab Rat
102 posts

[Solved] Exporting QWidgets to QML?

 

I’ve got an application which uses QWidgets.
Some special functionality is already implemented, for example I created an eventFilter that the enter key also changes the focus. I would also like to continue to use the validators, the setPlaceHolderText, setInputMask, etc. of the QLineEdit and some other built-in functionality of the QWidgets. Also, I could not find something similar to the QCombobox in QML.

Now I would like to add animations to my application. Is it possible to “export” the QWidgets to QML? Or how can I reuse my existing code when I would like to switch to QML?

I’m very new to QML, therefore I’m sorry if the answer is obvious. I would be really happy if you could recommend me some tutorials regarding this topic. Thank you!

8 replies

November 2, 2011

task_struct task_struct
Hobby Entomologist
344 posts

Hello,

see this article [doc.qt.nokia.com]

Also, you can use Qt Components [doc.qt.nokia.com]. They are available for Symbian, MeeGo and desktop.

 Signature 

“Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program.”
- Linus Torvalds

November 2, 2011

Andre Andre
Area 51 Engineer
6031 posts

I would recommend against the first approach. Yes, it is possible, but no, it is not a good idea. QGraphicsProxyWidget should IMO be avoided. It does not work properly, and is basically depricated due to it being a design flaw to begin with.

Go for the components if you can.

 Signature 

Looking for Qt developers to join our team @ i-Optics: https://qt-project.org/forums/viewthread/25393/

November 2, 2011

ephe ephe
Lab Rat
102 posts

Thank you, I already heard that QGraphicsProxyWidget should be avoided at the Qt Dev Days. Is there an alternative for it if I want to create my own components?

I saw that the native Qt Quick elements are derived from QDeclarativeItem. Maybe this helps when creating my own QML elements, but e.g. the QComboBox seems to be quite a lot of effort.

November 2, 2011

Andre Andre
Area 51 Engineer
6031 posts

Why don’t you look into how the Quick Desktop Compontents project creates combo boxes?
See here [qt.gitorious.org] for the sources and here [youtube.com] for the video.

 Signature 

Looking for Qt developers to join our team @ i-Optics: https://qt-project.org/forums/viewthread/25393/

November 3, 2011

ephe ephe
Lab Rat
102 posts

The Quick Desktop Components are amazing!
Are the Qt Components also available for Desktop? I saw that the Page and PageStack qmls are in Symbian / Meego folders.

Do you know if it is planned to include these components in the new QML version?

November 3, 2011

Andre Andre
Area 51 Engineer
6031 posts

They are not available yet in the sense of “officially released”, however the sources are there for you to use if you want. It is likely that a set of components like these will appear in a future version of Qt, but don’t count on it being there before Qt 5.1.

 Signature 

Looking for Qt developers to join our team @ i-Optics: https://qt-project.org/forums/viewthread/25393/

November 3, 2011

ephe ephe
Lab Rat
102 posts

That sounds good!

But it would still be nice if I could reuse all my QWidget dialogs and if I would not have to rebuild them.

November 3, 2011

Andre Andre
Area 51 Engineer
6031 posts

saho wrote:
But it would still be nice if I could reuse all my QWidget dialogs and if I would not have to rebuild them.

Don’t count on that. However, if you now have a good separation between your program logic and your UI, it should be easy to re-use at least the logic part of your application.

 Signature 

Looking for Qt developers to join our team @ i-Optics: https://qt-project.org/forums/viewthread/25393/

 
  ‹‹ How to set dynamically created component to the Loader.      [solved] map zoomout and zoomin problem ››

You must log in to post a reply. Not a member yet? Register here!