问题标签 [qt5.5]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
1631 浏览

qt - 如何在 QML 中动态更改“始终在顶部”窗口行为

如何通过例如切换Menu项目来改变行为?我尝试更改/设置标志:

标志已正确设置,但在更改时不会onTop.checked更改。

0 投票
1 回答
1334 浏览

qt - 为什么带有 NoWrap 的 TextArea 总是会导致“检测到锚循环”警告?

为什么是一个TextArea

总是导致

file:///C:/Qt/5.5/mingw492_32/qml/QtQuick/Controls/ScrollView.qml:340:13:QML 项目:在填充时检测到可能的锚循环。

当我运行它?

我在 64 位 Windows 7 机器上运行 Qt 5.5,并使用 MinGW 进行编译。

这是我的 QML 代码test.qml

这是我的 C++ 代码main.c

即使我添加anchors.fill: parentTextArea,我仍然会收到警告。

作为这个问题的第二部分,这个警告是我应该担心的,还是我可以放心忽略的?

0 投票
2 回答
1637 浏览

qt - 带有 Qt 5.5 的 OpenCV 3.0:工具栏图标和控制面板未显示

我构建了支持 Qt 的 OpenCV 3.0.0(Qt 5.5),以尝试一些高级的 HighGUI 功能:

我希望看到一个名为“Main”的窗口,它带有一个漂亮的工具栏以及一个包含按钮“test”的控制面板(请参见此处)。

我得到的是一个名为“Main”的窗口,带有一个工具栏,其中缺少图标(参见屏幕截图),并且根本没有出现控制面板。

截屏

这里有什么问题?

0 投票
4 回答
5960 浏览

c++ - 如何在我的 Qt 应用程序中存储密码?

如何在我的 Qt 应用程序中存储密码?

Qt 没有现成可用的库吗?

目前我通过QSettings存储我所有的应用程序配置。

0 投票
1 回答
1344 浏览

c++ - 从 C++ 设置创建的 qml 对象的父级不起作用

我有一个创建 QML 对象的 C++ 类,它需要五个参数:

我在 QML 中使用它如下:

在 C++ 上下文中,我可以正确打印我设置的属性的值,以及parent of the created object. However, when I print them from QML, thehas anull and the properties areundefined`。

我从 C++ 和 QML 打印了创建的对象的地址,我得到了相同的地址。我不明白是什么导致了这种行为。

谢谢你的帮助。

0 投票
1 回答
525 浏览

c++ - QT5.5 中 qDebug() 的新 QFlags 助手的问题

我有以下代码

用 qt5.5 编译它会给我以下错误:

其原因似乎在于 QDebug 头文件 (qdebug.h:277) 的以下代码:

使用 qt5.4 编译可以正常工作。取了正确的模板函数(qdatastream.h:241)

问题:

  1. 我想知道为什么要考虑 qdebug.h 中的模板。我有一些想法,但是带有与 c++ 标准的适当链接和正确解释的答案会很好。
  2. 是否有解决方法或者我应该向 qt 提交错误报告?
0 投票
1 回答
512 浏览

qt - Strange binding behavior when using binding on array's element

I have an Item with a property. This property contains an array of JavaScript objects wich in turn contain other properties.

When I set binding for one of object's properties to some variable and its (variable) value changes triggering the binding then all properties in the array are reset to their initial values. I've created a small demo to show the problem.

C++ code:

#xA;

QML code:

#xA;

Here is what I get:

qml: CLICK #1[RED SQUARE] : Set testObject.myArray[0] to TRUE qml: CLICK #1[RED SQUARE] : DONE

qml: CLICK #2[BLUE SQUARE] : Triggering notify by calling C++ <Test::valueChanged> method

qml: CLICK #2[BLUE SQUARE] : [BEFORE] testObject.myArray[0].name: CustomName, testObject.myArray[0].boolFlag: true qml: CLICK #2[BLUE SQUARE] : [AFTER] testObject.myArray[0].name: CustomName, testObject.myArray[0].boolFlag: false

So what happens here is that after I set testObject.myArray[0].boolFlag from false to true and call test.valueChanged() method, my flag automatically resets to its initial value. Same goes for any other type used - int, string, etc.

Why does this happen?

Visual Studio has update 4 installed.

0 投票
1 回答
366 浏览

c++ - 带有 QML 和注册类型的 QWidget 应用程序

我有一个使用 QML 的 QWidget 应用程序。我有一个类用于公开我们的一些组织实用功能。

我将问题归结为以下代码(我将在代码下方解释我的问题):

首先,这是main.cpp文件(为简洁起见,我排除了大部分文件includes):

这是包括的main.h

最后,这是我的 QML 文件:

我想要做的是将MyUtils类注册为单例,然后我可以将其包含在我的 QML 中并使用。问题是当我运行它时,我从应用程序的输出中得到以下消息:

QML 调试已启用。仅在安全的环境中使用。

Qml 调试已启用。只能在安全的环境中使用!

qrc:/main.qml:8: ReferenceError: myutils 未定义

我已经尝试在对象实例化之前放入 , qmlRegisterSingletonType(以及在其他各种地方进行咯咯笑),但到目前为止我还无法让它工作。main()QApplication

我注意到,如果我qDebug()在方法中放置断点或消息MyUtils::MyUtilsProvider,它永远不会被调用。这使我认为,也许我的MyView班级使用的QQmlEngine对象与qmlRegisterSingletonType注册单例的对象不同。但如果是这样的话,那么我不知道如何让那个引擎传递给MyView构造函数。

有人可以告诉我我做错了什么以及如何让它工作吗?

谢谢!

0 投票
2 回答
1881 浏览

qt - 如何使双 MouseArea 生效?

这是我的 QML 代码:

mouseArea1生效。如果我删除mouseArea1mouseArea2生效。所以我认为鼠标事件必须由mouseArea1它处理并且不能传递给mouseArea2.

我搜索文档以找出哪些 attr 可以防止这种行为,但没有找到。那么如何让mouseArea1和同时mouseArea2生效呢?

0 投票
3 回答
10282 浏览

qt - How to omit the "Binding loop detected for property" warning?

I decided to rewrite this question. I tried to make it clear and short but it didn't work out.

What I am trying to achieve is an object I can put on anything (Rectangle, Image and so on) and make it respond to touch gestures. Unfortunately I ran into a problem I cannot solve. I couldn't find help so I try here.

Here is simple main.qml:

and here is MyTouchSurface.qml

I want to have all calculating and functions within MyTouchSurface so it is easy to apply on other object and to use it in another project.

The problem I have is I don't know how to prevent target object from moving out of container. Well, the code here is working very nice but it also generates very ugly errors about binding loop.

What is going on is:

  • I check target's x and y when they changes
  • If the x or y is out of specified area I move them back
  • I receive signal "x changed" or "y changed" again
  • I receive error about loop because my function caused itself to execute again

So I am asking: Is there any other simple way to prevent object from flying off screen and not receive binding loop errors at the same time?

I know I can use Timer to check target's x and y from time to time, and bring them back.

I know I can change the easing and duration of the animation so it stops on the container bounds itself but looks like it was stopped.

Seriously. Is there no simple way?


Things that won't work:

  • stopping animation after object was detected outside container (if it would move really fast it will stop out of the screen )
  • stopping animation and then changing target's x or y

Thanks everyone helping me so far. It is nice to know I am not alone here :)