我正在 QML 中创建一个自定义类型,其Column内部有一个GroupBox. 当该类型的用户向其中添加组件时CustomType,它们应该位于Column,而不是GroupBox。如何在不制作额外包装文件的情况下实现这一点?
//CustomType.qml
GroupBox {
Column {
}
}
//Main.qml
CustomType {
CheckBox {//This should be inside the Column of the GroupBox in CustomType
}
}
Run Code Online (Sandbox Code Playgroud) I'm unable to assign ExclusiveGroup to my checkable buttons.
ExclusiveGroup {
id: group
onCurrentChanged: {
if(current != null) {
console.info("button checked...no!")
current = null
//current.checked = false <--- also this
}
}
}
Column {
width: parent.width
spacing: 0
Button {
id: btnScan
flat: true
text: qsTr("But1")
width: parent.width
checkable: true
exclusiveGroup: group
}
Button {
id: btnWhiteList
flat: true
text: qsTr("But2")
width: parent.width
checkable: true
exclusiveGroup: group
}
}
Run Code Online (Sandbox Code Playgroud)
The documentation states clearly that Button does have exclusiveGroup property …
我正在尝试使用QtQuick与C++文件中的qml对象进行交互。但遗憾的是暂时没有成功。知道我做错了什么吗?我尝试了两种方法,第一种方法的结果是findChild()返回了nullptr,第二次尝试时我收到Qml 组件未准备好错误。什么是正确的方法呢?
主要的:
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.load(QUrl(QLatin1String("qrc:/main.qml")));
if (engine.rootObjects().isEmpty())
return -1;
// 1-st attempt how to do it - Nothing Found
QObject *object = engine.rootObjects()[0];
QObject *mrect = object->findChild<QObject*>("mrect");
if (mrect)
qDebug("found");
else
qDebug("Nothing found");
//2-nd attempt - QQmlComponent: Component is not ready
QQmlComponent component(&engine, "Page1Form.ui.qml");
QObject *object2 = component.create();
qDebug() << "Property value:" << QQmlProperty::read(object, "mwidth").toInt();
return app.exec(); …Run Code Online (Sandbox Code Playgroud) 所以我有一个动态变化的饼图。我想在将鼠标悬停在切片上时显示每个切片的值,但我不确定如何在触发 onHovered 时创建工具提示。我用
qt 5.9.1 & 导入 QtQuick.Controls 2.2
更新:我添加了一些代码来解释我如何创建切片。这是代码:
function onUpdateValues(values){
switch(values.type){
case PIE_CHART:
createPieChart(values.data);
break;
...
default:
console.debug("CHART TYPE ERROR");
break;
}
}
}
function createPieChart(data){
pieserieschart.clear();
for (var prop in data) {
var new_slice = pieserieschart.append(prop, data[prop]);
new_slice.tooltip = prop + ": " + data[prop]
//I tried using hovered signal (and without), but it's not doing any difference
new_slice.hovered.connect(function(state) { new_slice.tooltip.visible = state })
//If I replace the above line by the next one, I can …Run Code Online (Sandbox Code Playgroud) 我使用 Qt 和 QtQuick 技术开发了一个跨平台应用程序。与后端服务器的通信由 Let's Encrypt SSL 保护。
但在 2021 年 9 月,Qt 应用程序开始报告“SSL 握手失败”错误,而客户端或服务器没有任何更改。问题是什么?
http://doc.qt.io/qt-5/qtqml-qmlmodule.html
QtQml和QtQuick似乎是不同的东西,这就是为什么有两个单独的import语句.
import QtQml 2.2
import QtQuick 2.3
QtQml和QtQuick之间有什么区别,在哪些现实案例中应该使用它们?