从Qt4.7开始,我们就可以使用qml编写界面,那时我们需要import QtQuick 1.0即可。
网上很多代码都是Qt4.X系列的,估计曾经的诺基亚很火的原因,现在很多教程都跟不上位。很早就进入Qt5.0的时代,虽然一直以Qt4.系列自学。
但总有一天要进入5的怀抱的,不过如果你是黑莓开发,一些嵌入式相关的话,很多还是跟4相关的编译器,可以暂时有个家。
以下一般是网上搜索或是自己经历的,记录如下:
原文(由QtQuick1.1转到QtQuick2.0的注意事项):
I don’t understand what you mean in the second part of your post. I think you might have run into problems because you are trying to run Qt4 code under Qt5. There are some (small) source-incompatible changes in Qt5, that you have to address. You can search the docs and wiki for more info, but just as a quick recap:
QDeclarativeView *view = new QDeclarativeView(this); QHBoxLayout* layout = new QHBoxLayout(this); layout->addWidget(this);this指针这里指向是继承QWidget的类。
QuickView *view = new QQuickView(); QWidget *container = QWidget::createWindowContainer(view,this); QHBoxLayout* layout = new QHBoxLayout(this); layout->addWidget(container);我们发现Qt5.x就会比之前多了一个包装,至于为什么这样,是因为QDeclarativeView它是继承QWidget类的,而现在的QQuickView是继承QWindow类的,并且这两个不是