我从一个新的QtQuick2项目开始,使用Ubuntu 12.04和Mac OSX。我已经在Qt 5.3.1和5.3.2上尝试过了。
我使用这段代码创建了一个设置为OpenGL 4.1核心配置文件的QQuickView。
QApplication app(argc, argv);
QQuickView * m_pMainView = new QQuickView;
QSurfaceFormat f;
f.setProfile(QSurfaceFormat::CoreProfile);
f.setVersion(4, 1);
m_pMainView->setFormat(f);
m_pMainView->setSource(QUrl("qrc:///main.qml"));
m_pMainView->show();
return app.exec();
我的QML很简单。
import QtQuick 2.3
import QtQuick.Controls 1.2
Rectangle {
visible: true
height: 800
width: 600
Label {
text: "Test"
}
}
运行此代码会立即导致应用程序崩溃。将QML中的Label控件切换为Text控件,不会崩溃,正常运行。将QSurfaceFormat切换为适用的兼容性配置文件(Ubuntu上的3.3 / Mac上的2.1),不会崩溃,正常运行。
我在更改OpenGL版本时是否做错了什么,还是Qt 5.3在核心配置文件方面不稳定?
如果有用的话,这里是来自Mac的堆栈跟踪:
Thread 6 Crashed:: QSGRenderThread
0 QtGui 0x0000000101cd41a7 QOpenGLContextPrivate::maxTextureSize() + 343
1 QtGui 0x0000000101f33907 QOpenGLTextureGlyphCache::maxTextureHeight() const + 39
2 QtGui 0x0000000101ec4137 QTextureGlyphCache::populate(QFontEngine*, int, unsigned int const*, QFixedPoint const*) + 1687
3 QtQuick 0x0000000100d488f0 QSGTextMaskMaterial::populate(QPointF const&, QVector<unsigned int> const&, QVector<QPointF> const&, QSGGeometry*, QRectF*, QPointF*, QMargins const&) + 432
4 QtQuick 0x0000000100d473fd QSGDefaultGlyphNode::update() + 797
5 QtQuick 0x0000000100dc7632 QQuickTextNode::addGlyphs(QPointF const&, QGlyphRun const&, QColor const&, QQuickText::TextStyle, QColor const&, QSGNode*) + 482
6 QtQuick 0x0000000100dcbc61 QQuickTextNodeEngine::addToSceneGraph(QQuickTextNode*, QQuickText::TextStyle, QColor const&) + 2049
7 QtQuick 0x0000000100dc7fbd QQuickTextNode::addTextLayout(QPointF const&, QTextLayout*, QColor const&, QQuickText::TextStyle, QColor const&, QColor const&, QColor const&, QColor const&, int, int, int, int) + 557
8 QtQuick 0x0000000100dc5368 QQuickText::updatePaintNode(QSGNode*, QQuickItem::UpdatePaintNodeData*) + 1000
9 QtQuick 0x0000000100d88995 QQuickWindowPrivate::updateDirtyNode(QQuickItem*) + 3317
10 QtQuick 0x0000000100d7fdb2 QQuickWindowPrivate::syncSceneGraph() + 306
11 QtQuick 0x0000000100d5d388 QSGRenderThread::sync() + 120
12 QtQuick 0x0000000100d5d475 QSGRenderThread::syncAndRender() + 117
13 QtQuick 0x0000000100d5d968 QSGRenderThread::run() + 200
14 QtCore 0x00000001016923f2 QThreadPrivate::start(void*) + 338
15 libsystem_pthread.dylib 0x00007fff94d23899 _pthread_body + 138
16 libsystem_pthread.dylib 0x00007fff94d2372a _pthread_start + 137
17 libsystem_pthread.dylib 0x00007fff94d27fc9 thread_start + 13