如何显示屏幕并运行一些“后台”任务(不带线程)
我正在尝试开发一个用于触摸屏的 Qt 应用程序;该应用程序在 ARM 系统上运行,使用 Qt Everywhere 4.7.2。
在此应用程序中,我需要显示特定的登录屏幕;然后用户按下“确定”按钮,我必须验证输入的信息是否正确。为此,我需要向我的服务器发送一条消息,在执行此操作时,我想显示一个等待屏幕。我已经有一些课程允许我在屏幕之间切换,并且它有效。问题是:当我在显示请求之后放置一些代码时,它被执行但屏幕不显示!
一个例子:
display_->CloseActualScreen();
display_->SetScreenId( MTO_Display::WAITING_SCREEN );
display_->ChooseScreenToDisplay();
这基本上是我在屏幕之间切换的方式; display_
是一个特定的对象。 CloseActualScreen()
方法通过删除其对象来关闭正在显示的屏幕。然后,ChooseScreenToDisplay()
根据屏幕 ID 创建并显示一个新的小部件。如果需要,我可以放置这些方法的代码,但如果我像那样使用它们,它们就会起作用。
然后,如果我这样做:
display_->CloseActualScreen();
display_->SetScreenId( MTO_Display::WAITING_SCREEN );
display_->ChooseScreenToDisplay();
CallToAnotherFunction();
CallToAnotherFunction() 执行得很好,但这里根本不显示我的等待屏幕;我认为这种行为没有任何理由!
你有主意吗?
谢谢 !
I am trying to develop a Qt application for a touchscreen ; this application is running on an ARM system, with Qt Everywhere 4.7.2.
In this application, I need to display a specific screen for login ; then the user press an "Ok" button, and I must verify if the informations entered are correct. To do that, I need to send a message to my server and while doing that, I would like to display a waiting screen. I have already a some classes that allow me to switch between screens, and it works. The problem is : when I put some code after the display request, it is executed but the screen doesn't display !
An example :
display_->CloseActualScreen();
display_->SetScreenId( MTO_Display::WAITING_SCREEN );
display_->ChooseScreenToDisplay();
It is basically the way I switch between screen ; display_
is a specific object. The method CloseActualScreen()
closes the screen being display by deleting its object. Then ChooseScreenToDisplay()
creates and display a new widget depending on the screen id. I can put these method's code if needed, but they work if I used them like that.
Then, if I do that :
display_->CloseActualScreen();
display_->SetScreenId( MTO_Display::WAITING_SCREEN );
display_->ChooseScreenToDisplay();
CallToAnotherFunction();
CallToAnotherFunction()
is well executed but here my waiting screen is not displayed at all ; I see no reason for this behavior !
Do you have an idea ?
Thanks !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
arg x)我搜索了两天,在这里询问后找到了解决方案... x)我需要使用 QApplication::processEvents 以便在执行其余代码之前处理所有事件。
Arg x) I searched on this for two days, and found the solution just after asking here... x) I need to use QApplication::processEvents in order to process all events before executing the rest of the code.