• 5375阅读
  • 9回复

[提问]想实现一个动态的splash screen [复制链接]

上一主题 下一主题
离线roywillow
 

只看楼主 倒序阅读 楼主  发表于: 2012-05-10
Qt提供的QSplashScreen只能实现静态的splash screen。我想实现一个动态的效果,但是按照文档中的那种方法的话,窗口是在消息循环启动之前创建和显示的,所以定时器之类的似乎就完全没有效果了,自然也就不好实现动态效果……
请问各位有什么比较好的想法?
专业维修核潜艇,回收二手航母、二手航天飞机,大修核反应堆,拆洗导弹发动机更换机油,无人侦察机手动挡改自动,航天飞机保养换三滤,飞碟外太空年检 ,各型号导弹加装迎宾踏板,高空作业擦洗卫星表面除尘、打蜡及抛光,东风全系列巡航导弹。并提供原子对撞机。量大从优,有正规发票。
离线roywillow

只看该作者 1楼 发表于: 2012-05-11
好吧……大概又要石沉大海了……
专业维修核潜艇,回收二手航母、二手航天飞机,大修核反应堆,拆洗导弹发动机更换机油,无人侦察机手动挡改自动,航天飞机保养换三滤,飞碟外太空年检 ,各型号导弹加装迎宾踏板,高空作业擦洗卫星表面除尘、打蜡及抛光,东风全系列巡航导弹。并提供原子对撞机。量大从优,有正规发票。
离线benbenmajia

只看该作者 2楼 发表于: 2012-05-11
你试过timer么?
安然.....
离线benbenmajia

只看该作者 3楼 发表于: 2012-05-11
A splash screen is a widget that is usually displayed when an application is being started. Splash screens are often used for applications that have long start up times (e.g. database or networking applications that take time to establish connections) to provide the user with feedback that the application is loading.
The splash screen appears in the center of the screen. It may be useful to add the Qt::WindowStaysOnTopHint to the splash widget's window flags if you want to keep it above all the other windows on the desktop.
Some X11 window managers do not support the "stays on top" flag. A solution is to set up a timer that periodically calls raise() on the splash screen to simulate the "stays on top" effect.The most common usage is to show a splash screen before the main widget is displayed on the screen. This is illustrated in the following code snippet in which a splash screen is displayed and some initialization tasks are performed before the application's main window is shown:
安然.....
离线roywillow

只看该作者 4楼 发表于: 2012-05-11
回 2楼(benbenmajia) 的帖子
没有
但是splash是在事件循环开始前显示的,执行exec()时splash已经析构了,所以应该没用
除非我等事件循环开始了再进行各种处理……?
专业维修核潜艇,回收二手航母、二手航天飞机,大修核反应堆,拆洗导弹发动机更换机油,无人侦察机手动挡改自动,航天飞机保养换三滤,飞碟外太空年检 ,各型号导弹加装迎宾踏板,高空作业擦洗卫星表面除尘、打蜡及抛光,东风全系列巡航导弹。并提供原子对撞机。量大从优,有正规发票。
离线benbenmajia

只看该作者 5楼 发表于: 2012-05-11
回 4楼(roywillow) 的帖子
The user can hide the splash screen by clicking on it with the mouse. Since the splash screen is typically displayed before the event loop has started running, it is necessary to periodically call QApplication::processEvents() to receive the mouse clicks.

这是splash提供的时间处理办法
安然.....
离线roywillow

只看该作者 6楼 发表于: 2012-05-11
回 5楼(benbenmajia) 的帖子
那么如果我想播放一个gif动画的话,该怎么调用?每更新一帧都是个事件吧……
专业维修核潜艇,回收二手航母、二手航天飞机,大修核反应堆,拆洗导弹发动机更换机油,无人侦察机手动挡改自动,航天飞机保养换三滤,飞碟外太空年检 ,各型号导弹加装迎宾踏板,高空作业擦洗卫星表面除尘、打蜡及抛光,东风全系列巡航导弹。并提供原子对撞机。量大从优,有正规发票。
离线kimtaikee

只看该作者 7楼 发表于: 2012-05-12
不要把思维只局限于QSplashWindow,你可以创建一个Pre-stage window ,在这个window中已经有了消息循环,你可以演示动画,结束之后你发射个信号告诉主程序,它的使命开始了!
  1. // prewindow.h
  2. class RealWindow;
  3. class PreWindow : public QWidget
  4. {
  5.    ...
  6.   private Q_SLOTS:
  7.   void FireupMasterWindow();
  8.   Q_SIGNALS:
  9.   void sig_ItsYourTurn();
  10. }
  11. // prewindow.cpp
  12. RealWindow::RealWindow(QWidget* parent):QWidget(parent)
  13. {
  14.   connect(this,SIGNAL(sig_ItsYourTurn()),SLOT(FireupMasterWindow()));
  15. }
  16. void RealWindow::FireupMasterWindow()
  17. {
  18.   RealWindow* pRW = new RealWindow;
  19.   pRW->show();
  20. }
  21. int main(int argc,char** argv)
  22. {
  23.    QApplication app(argc,argv);
  24.    PreWindow win;
  25.    win.show();
  26.    return app.exec();
  27. }


离线benbenmajia

只看该作者 8楼 发表于: 2012-05-14
回 6楼(roywillow) 的帖子
除了9L的这种方法之外,你也可以使用QProcess,在你的UIshow之前调用另外一个process来演示你的动画。
安然.....
离线benbenmajia

只看该作者 9楼 发表于: 2012-05-14
gif的动画可以直接使用PHONON播放
安然.....
快速回复
限100 字节
 
上一个 下一个