zoukankan      html  css  js  c++  java
  • Qt通用方法及类库1

    函数名

    //桌面宽度高度
    static int deskWidth();
    static int deskHeight();
    
    //程序文件名称+当前所在路径
    static QString appName();
    static QString appPath();
    
    //初始化随机数种子
    static void initRand();

    函数体

    int QUIHelper::deskWidth()
    {
        //没有必要每次都获取,只有当变量为空时才去获取一次
        static int width = 0;
        if (width == 0) {
            width = qApp->desktop()->availableGeometry().width();
        }
    
        return width;
    }
    
    int QUIHelper::deskHeight()
    {
        //没有必要每次都获取,只有当变量为空时才去获取一次
        static int height = 0;
        if (height == 0) {
            height = qApp->desktop()->availableGeometry().height();
        }
    
        return height;
    }
    
    QString QUIHelper::appName()
    {
        //没有必要每次都获取,只有当变量为空时才去获取一次
        static QString name;
        if (name.isEmpty()) {
            name = qApp->applicationFilePath();
            QStringList list = name.split("/");
            name = list.at(list.count() - 1).split(".").at(0);
        }
    
        return name;
    }
    
    QString QUIHelper::appPath()
    {
    #ifdef Q_OS_ANDROID
        return QString("/sdcard/Android/%1").arg(appName());
    #else
        return qApp->applicationDirPath();
    #endif
    }
    
    void QUIHelper::initRand()
    {
        //初始化随机数种子
        QTime t = QTime::currentTime();
        qsrand(t.msec() + t.second() * 1000);
    }
  • 相关阅读:
    bootstrap 弹出框(Popover)插件 修改title等属性选项值
    dedecms 搬家流程
    jQuery ui 百叶窗blind方向设置
    css 优先级
    dedecms 标签
    dedecms 建站相关问题
    css 透明度使用
    css 边框使用
    css 阴影使用
    js 常用判断
  • 原文地址:https://www.cnblogs.com/sggggr/p/12934991.html
Copyright © 2011-2022 走看看