我想在QML Scene3D中添加一个C++ QEntity,如下所示:
//C++
class MapEntity : public Qt3DCore::QEntity {
public:
MapEntity( Qt3DCore::QEntity* parent ) : Qt3DCore::QEntity(parent) {
...
}
}
// QML
Scene3D {
MapEntity {
id: map
...
}
}
Run Code Online (Sandbox Code Playgroud)
可能吗?如果是的话,该怎么做?
或者也许可以创建C++场景(例如Qt3DExtras :: Qt3DWindow)并在QML中使用?
我有一个依赖于 Google 测试库的 CMake 项目。我已经添加了谷歌测试使用ExternalProject_Add和add_subdirectory描述here(https://github.com/google/googletest/tree/master/googletest部分Incorporating Into An Existing CMake Project)。
现在,命令后,add_subdirectory我要检查包括项目的版本gtest和gmock,但是gtest_VERSION和gmock_VERSION变量是不明确的。是否可以通过添加项目版本add_subdirectory?
如何更改 Qt3D 中的灯光设置?
我认为它应该是 framegraph 的一部分,但是在标准转发器中没有任何与灯光设置相关的方法。
我需要制作AbstractButton应该是独占的可检查列表,但默认情况下我无法取消选中未选中任何按钮的已选中按钮。
现在我必须做这样的事情来模仿这样的逻辑:
Item {
AbstractButton {
id: oneButton
checkable: true
onCheckedChanged: {
if(checked) {
if(twoButton.checked || threeButton.checked || ...) {
twoButton.checked = threeButton.checked = ... = false
}
}
}
}
AbstractButton {
id: twoButton
checkable: true
onCheckedChanged: {
if(checked) {
if(oneButton.checked || threeButton.checked || ...) {
oneButton.checked = threeButton.checked = ... = false
}
}
}
}
...
}
Run Code Online (Sandbox Code Playgroud)
这很丑陋,如果能找到更好的解决方案那就太好了。
我使用Qt Quick Controls 2时出现弹出窗口大小行为的问题.当我将ListView作为弹出窗口的contentItem时,弹出窗口大小为零.一些重现问题的示例代码:
import QtQuick 2.4
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3
ApplicationWindow {
id: window
visible: true
width: 800
height: 600
Button {
text: "open popup"
onClicked: popup.open()
}
Popup {
id: popup
x: (window.width - width) / 2
y: window.height / 6
width: contentWidth
height: contentHeight
contentItem: ListView {
width: contentWidth
height: contentHeight
model: ListModel {
ListElement {
name: "Apple"
cost: 2.45
}
ListElement {
name: "Orange"
cost: 3.25
}
ListElement {
name: "Banana"
cost: 1.95
} …Run Code Online (Sandbox Code Playgroud)