Chinaunix首页 | 论坛 | 博客
  • 博客访问: 141673
  • 博文数量: 29
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 265
  • 用 户 组: 普通用户
  • 注册时间: 2014-01-04 13:11
文章分类

全部博文(29)

文章存档

2015年(2)

2014年(27)

我的朋友

分类: 嵌入式

2014-08-27 15:17:27


一,Qt中显示程序启动画面的方法
#include
#include
#include
#include "mainwindow.h"


int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    QSplashScreen *splash = new QSplashScreen;
    splash->setPixmap(QPixmap(":/images/Open.png"));
    splash->show();
    app.processEvents();


    QDateTime n=QDateTime::currentDateTime();
    QDateTime now;
    Qt::Alignment topRight = Qt::AlignRight | Qt::AlignTop;
    splash->showMessage(QObject::tr("setting up the main window"),
                       topRight,Qt::white);
    do{
        now=QDateTime::currentDateTime();
    } while (n.secsTo(now)<=5);//3为需要延时的秒数


    MainWindow mainWin;
    mainWin.show();
    splash->finish(&mainWin);
    delete splash;
    return app.exec();
}

                                                        二,Qt中显示窗体部件QSpinBox的方法
#include
#include


int main(int argc,char* argv[])
{
    QApplication  app(argc,argv);
    QSpinBox *spinbox = new QSpinBox;
    spinbox->setSingleStep(2);     //每步跳动间隔
    spinbox->setRange(0,100);       //设置变化范围
    spinbox->setSuffix("km");       //设置输出显示前缀
    spinbox->setPrefix("");  //设置输出显示后缀
    spinbox->resize(100,40);        //设置大小
    spinbox->setValue(50);          //设置初始值
    spinbox->show();
    return app.exec();


}



阅读(1926) | 评论(0) | 转发(0) |
0

上一篇:Qt学习(一)

下一篇:名词解释

给主人留下些什么吧!~~