QT 之启动画面

程序启动之前有时候需要一段时间来加载, 为了避免用户感觉程序死机卡顿的情况,特别加上开机界面,提醒用户程序正在执行中.

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    
    std::string cur_path("");
    if (!Logging::GetCurrentPath(cur_path))
    {
        std::cout << "Get current path failed!" << std::endl;
    }
    cur_path += std::string(project_name) + std::string("/");

    std::string  img_path += cur_path + std::string("/") + std::string("loginImage.png") ;
    QString str_tmp = QString::fromStdString(img_path);
    QSplashScreen *splash = new QSplashScreen;
    QPixmap pixmap(str_tmp);
    pixmap = pixmap.scaled(400,400,Qt::KeepAspectRatio);
    splash->setPixmap(pixmap);
    splash->setFont((QFont("Helvetica",20)));
    splash->show();
    Qt::Alignment topLeft = Qt::AlignLeft|Qt::AlignTop;
    splash->showMessage("系统启动中,请稍等...",topLeft,Qt::white);
    a.processEvents();

    MainDlg s(cur_path);
    s.show();
    splash->finish(&s);
    delete splash;

    return a.exec();
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ppipp1109

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值