标签:string spl 通用 count ble empty split 函数名 des
//桌面宽度高度 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); }
标签:string spl 通用 count ble empty split 函数名 des
原文地址:https://www.cnblogs.com/sggggr/p/12934991.html