问题描述
我正在尝试在基于 QtWidget 的应用程序中使用 qml 小部件
I'm trying to use qml widget in QtWidget-based application like that
QQuickView *view = new QQuickView;
view->setSource(QUrl::fromLocalFile("myqml.qml"));
QWidget *widget = QWidget::createWindowContainer(view);
widget->setMinimumSize(100, 100);
widget->setMaximumSize(1000, 1000);
widget->setFocusPolicy(Qt::TabFocus);
widget->show();
而且该代码不适用于组合框,它们的列表位于错误的位置,看起来 Qt 会计算它们相对于屏幕的位置.
And that code doesn't work right with comboBoxes, their list falls in the wrong place, it looks like Qt calculate their position relative to the screen.
如果我不使用小部件并这样做
If I don't use widget and do
view->show()
它工作正常,但我需要使用小部件,将其放入 QSplitter 或 QLayout.
it works fine, but I need to use widget, to put it in QSplitter or QLayout.
有没有办法让它工作或以其他方式将基于 qml 的小部件放入 QSplitter/QLayout.
Is there a way to make it work or some other way to put qml-based widget in QSplitter/QLayout.
推荐答案
这个bug将在Qt5.1.2 (Next Patch Release) 和Qt5.2.0 (Next Minor Release)中修复
This bug will be fixed in Qt5.1.2 (Next Patch Release) and Qt5.2.0 (Next Minor Release)
这篇关于组合框掉在了错误的地方的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!