天道酬勤,学无止境

qquickwidget

在 QStackedWidget 中添加 QQuickWidget(Adding QQuickWidget in QStackedWidget)

问题 我正在尝试在 qstackedwidget 中添加一个 qquickwidget 以及其他一些 qwidget。 但是当我尝试将当前小部件设置为 qquickwidget 时,窗口上没有任何显示。 还有什么需要做的吗? 我还将 qquickwidget 的视图属性设置为 true QQuickWidget* mRoom = new QQuickWidget; connect(mRoom, SIGNAL(statusChanged(QQuickWidget::Status)), this, SLOT(StatusChanged(QQuickWidget::Status))); mRoom->setSource(QUrl::fromLocalFile("C:/Users/visjain/Desktop/main_vishwas.qml")); mRoom->setResizeMode(QQuickWidget::SizeRootObjectToView); QStackedWidget* mStack = new QStackedWidget(mparent); mStack->addWidget(mRoom); mStack->setCurrentWidget(mRoom); mRoom->show(); qml代码- import QtQuick 2.5 import

2021-11-12 16:00:30    分类:技术分享    qt   qml   qstackedwidget   qquickwidget

Adding QQuickWidget in QStackedWidget

I am trying to add a qquickwidget along with some other qwidgets in qstackedwidget. But when I am trying to set the current widget to the qquickwidget nothing appears on the window. Is there something else that need to be done? I am also setting the view property of the qquickwidget to true QQuickWidget* mRoom = new QQuickWidget; connect(mRoom, SIGNAL(statusChanged(QQuickWidget::Status)), this, SLOT(StatusChanged(QQuickWidget::Status))); mRoom->setSource(QUrl::fromLocalFile("C:/Users/visjain/Desktop/main_vishwas.qml")); mRoom->setResizeMode(QQuickWidget::SizeRootObjectToView); QStackedWidget*

2021-11-11 06:43:40    分类:问答    qt   qml   qstackedwidget   qquickwidget

QQuickWidget:grabToImage:项目的窗口不可见(QQuickWidget: grabToImage: item's window is not visible)

问题 当我尝试使用 Item::grabToImage() qml 方法时遇到问题。 无论我指向哪个项目,它总是说以下错误: 抓取到图像:项目的窗口不可见 我也尝试使用名为 rect 的根/顶级项目,但它没有用。 我的目标:我想捕获一个矩形大小的图像,上面有地图图块和多边形绘制 下面是一个最小的可重现示例 import QtQml 2.2 import QtLocation 5.9 import QtPositioning 5.9 import QtQuick 2.0 import QtQuick.Controls 2.4 Item { id: rect width: 1024 height: 768 visible: true Plugin { id: mapPlugin name: "osm" } Map { id: map enabled: true visible: true parent: rect gesture.enabled: true anchors.fill: parent plugin: mapPlugin zoomLevel: 14 activeMapType: supportedMapTypes[3] } Item { anchors.bottom: parent.bottom anchors.left: parent.left anchors.right

2021-10-25 20:46:57    分类:技术分享    qt   qml   qt5   qquickwidget

QQuickWidget: grabToImage: item's window is not visible

I'm having a problem when I try to use Item::grabToImage() qml method. No matter which item I point to, it always says the following error: grabToImage: item's window is not visible I tried using the root/toplevel Item named rect too, but it didnt work. My goal: I want to capture a rectangle sized image with the map tile and polygon draw on it Below there's a minimal reproducible example import QtQml 2.2 import QtLocation 5.9 import QtPositioning 5.9 import QtQuick 2.0 import QtQuick.Controls 2.4 Item { id: rect width: 1024 height: 768 visible: true Plugin { id: mapPlugin name: "osm" } Map {

2021-10-19 19:54:07    分类:问答    qt   qml   qt5   qquickwidget

QQuickWidget 抓取图片(QQuickWidget grab image)

问题 我正在保存带有几个 QML 子项的QQuickWidget的图像,但我只有一张空白图像。 C++方面: QQuickWidget* content.. content->setSource(QUrl("qml:/main.qml")); QPixmap *pm = content->grab(QRect(QPoint(0,0),QSize(-1,-1)); pm->save("someFilename.png", 0, 100); QML方面: Rectangle{ width: 5; height: 5; color: "yellow"; objectname: "rootobj"} 在 QML 中,我希望动态添加子项并能够在图像中显示它们。 我已经尝试过连接到插槽的QQuickWindow grabWindow方法,它可以工作,但它只捕获窗口可见区域,我需要捕获整个 QML。 我相信这不是火箭科学,只是我没有在某个地方得到它。 感谢您的回复! 附录: 好的,我不认为这是渲染前/渲染后的问题,因为在调用图片抓取器之前我可以看到所有 qml 子项。 很抱歉没有准确。 C++方面: QQuickWidget* content.. content->setSource(QUrl("qml:/main.qml")); //do all my dynamic qml children

2021-06-22 07:06:44    分类:技术分享    qt   qml   qtquick2   qquickwidget

QQuickWidget grab image

I am saving an image of a QQuickWidget with several QML children but all I have is a blank image. C++ side: QQuickWidget* content.. content->setSource(QUrl("qml:/main.qml")); QPixmap *pm = content->grab(QRect(QPoint(0,0),QSize(-1,-1)); pm->save("someFilename.png", 0, 100); QML side: Rectangle{ width: 5; height: 5; color: "yellow"; objectname: "rootobj"} In the QML I wish to dynamically add children and be able to show them in the image. I have tried QQuickWindow grabWindow method with a connection to a slot and it works but it captures only the window visible area and I need to capture the

2021-05-09 09:04:52    分类:问答    qt   qml   qtquick2   qquickwidget