http://qt-project.org/doc/qt-4.8/qtb...ing-qml-with-c
there you go, have a read.
Not sure what you're talking about. The only way to access the QML stuff is... QML. You can't get to it through C++.
Look at http://labs.qt.nokia.com/2012/08/08/...-text-in-qml-2 for example:
renderType? What is that? How do I set it to "Text.NativeRendering" through C++?Code:Text { text: "Some text" renderType: Text.NativeRendering }
http://qt-project.org/doc/qt-4.8/qtb...ing-qml-with-c
there you go, have a read.
I guess that would be one way. There are errors in there and i left out a lot of boilerplate (so that won't compile) but it's the same idea, i think.Code:#include <QtGui/QMainWindow> #include <QtGui/QWidget> QMainWindow *window = new QMainWindow; window->setMinimumSize(100, 100); QWidget *rectangle = new QWidget(window); item->setObjectName("rect"); window->setCentralWidget(rectangle);
ps: that anchors.fill property i think is covered by layout contained in a QMainWindow central widget area. i don't really know much QML, so that's just an educated guess.
Last edited by GabrielYYZ; 08-17-2012 at 04:42 PM.
2 things for clarification
1.) the theme on screenshot is NOT GTK is QT internal Theme plastic which is in every version of QT since 2.x and is selectable using qtconfig
1.a) Oxygen is part of KDE not QT and since the ABI changed is perfectly normal it doesnt load but it will be ported once KDE5 starts[i think is WIP now]
1.b) The font issue is probably an antialiasing setting since normally you set it from KDE or the render backend used, i guess we have to wait until KDE5 reach alpha 1
2.) QML uses scenegraph and yes is JS and it has some feature the C++ codepath miss but you still can write your app 100% in C++ or in mixed mode [QML gui / logic C++], so for now QML is like QtScript was an AddOn that provide some goodies and i very likely due to pressure that scenegraph will become available for C++ API in a subsequent revision but is not like Qt is 100% javascript now or anything like it
Qt Quick doesn't use QWidget-derived classes. It's a completely new GUI implementation. And you can't use that new implementation from C++. It's a QML-exclusive. Only QML gets to access it. And I find that sad.
So the code you posted has nothing to do with the QML code. Not even at the lowest level; different code is used for Qt Quick.
I think it was said in a Blog, they want you to do the UI code in QML and logic in C++.
Anyways, QML uses it's own widgets like you said, so Qwidget will still be the preferred way of doing desktop applications as only it uses the native style. The QML desktop components won't make it until Qt 5.1 (from what I have heard, could be wrong here).
I don't really get what you're saying or what you're sad about...
I agree that Qt Quick doesn't use QWidget-derived classes and that it's a completely new way to do GUI but you can use it from C++ (see QDeclarativeEngine). The code i posted is not how you would interface with QML, it's just a way to do that QML thing using C++ widgets. To use QML objects from c++, the link i posted explains how to do it.