首页| 论坛| 消息

标题:在读写文件的时候C++调用QML窗口失效
作者:robin-zf
日期:2017-08-30 11:16
内容:

写了一个程序,C++里实现业务把N个文件的内容读出来,然后把内容写到另一个文件。读写文件时想调用一个进度条窗口,显示读到第几个文件。可是运行程序时,进度窗口显示的内容就是不出来,一定要等到读完写完,它才显示进度条。Wprocess.qml:import QtQuick 2.0
import QtQuick.Controls 2.0
import QtQuick.Controls 1.4 as Control
import QtQuick.Controls.Styles 1.4
import QtGraphicalEffects 1.0
ApplicationWindow{
id:wprocess
width: 400;
height: 100;
visible: true
Text {
id:dir1
objectName: "text1"
text: "正在读取文件夹"
font.pixelSize: 12
anchors.top:parent.top
anchors.topMargin: 10
anchors.left: parent.left
anchors.leftMargin: 4
}
Control.ProgressBar{
id:processbar1
objectName: "bar1"
minimumValue: 0
maximumValue: 100
value: 0
width: 390
height: 20
anchors.top:dir1.bottom
anchors.topMargin: 4
anchors.left: parent.left
anchors.leftMargin: 2
&nbsp ..


#1 [never_forget 08-31 08:34]
哪有你这样玩儿的,干嘛要这么写啊,这个当然是加载 QML 文件,然后注册 C++ 类到 QML 上下文,然后绑定信号,刷新界面啊。你这个写法是哪找来的,这个在读取文件的时候可能阻塞了进程,所以 QML 还不能显示了,文件操作完成了才显示界面!

回复 发表
主题 版块