In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "the general method of Qt and how to use the class library". In the daily operation, I believe that many people have doubts about the general method of Qt and how to use the class library. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "the general method of Qt and how to use the class library". Next, please follow the editor to study!
Function name / / sets the label color static void setLabStyle (QLabel * lab, quint8 type, const QString & bgColor = "", const QString & textColor = ""); / / sets the form center display static void setFormInCenter (QWidget * frm); / / sets the translation file static void setTranslator (const QString & qmFile = ": / image/qt_zh_CN.qm"); / / sets the encoding static void setCode () / / set delay static void sleep (int msec); / / set system time static void setSystemDateTime (const QString & year, const QString & month, const QString & day, const QString & hour, const QString & min, const QString & sec); / / set boot static void runWithSystem (const QString & strName, const QString & strPath, bool autoRun = true) Function body void QUIHelper::setLabStyle (QLabel * lab, quint8 type, const QString & bgColor, const QString & textColor) {QString colorBg = bgColor; QString colorText = textColor; / / enable the new color if (bgColor.isEmpty ()) if the new color is set | | textColor.isEmpty () {if (type = 0) {colorBg = "# D64D54"; colorText = "# FFFFFF" } else if (type = = 1) {colorBg = "# 17A086"; colorText = "# FFFFFF";} else if (type = = 2) {colorBg = "# 47A4E9"; colorText = "# FFFFFF";} else if (type = = 3) {colorBg = "# 282D30"; colorText = "# FFFFFF" } else if (type = = 4) {colorBg = "# 0E99A0"; colorText = "# FFFFFF";} else if (type = = 5) {colorBg = "# A279C5"; colorText = "# FFFFFF";} else if (type = = 6) {colorBg = "# 8C2957"; colorText = "# FFFFFF" } else if (type = = 7) {colorBg = "# 04567E"; colorText = "# FFFFFF";} else if (type = = 8) {colorBg = "# FD8B28"; colorText = "# FFFFFF";} else if (type = = 9) {colorBg = "# 5580A2"; colorText = "# FFFFFF" } QStringList qss; / / disable color qss width (); int frmY = frm- > height (); QDesktopWidget w; int deskWidth = w.availableGeometry (). Width (); int deskHeight = w.availableGeometry (). Height (); QPoint movePoint (deskWidth / 2-frmX / 2, deskHeight / 2-frmY / 2); frm- > move (movePoint);} void QUIHelper::setTranslator (const QString & qmFile) {QTranslator * translator = new QTranslator (qApp) Translator- > load (qmFile); qApp- > installTranslator (translator);} void QUIHelper::setCode () {# if (QT_VERSION 0) {# if (QT_VERSION < QT_VERSION_CHECK) QTime endTime = QTime::currentTime (). AddMSecs (msec); while (QTime::currentTime () < endTime) {QCoreApplication::processEvents (QEventLoop::AllEvents, 100);} # else QThread::msleep (msec) # endif}} void QUIHelper::setSystemDateTime (const QString & year, const QString & month, const QString & day, const QString & hour, const QString & min, const QString & sec) {# ifdef Q_OS_WIN QProcess p (0); p.start ("cmd"); p.waitForStarted (); p.write (QString ("date% 1 UV% 2murf% 3\ n") .arg (year) .arg (month) .arg (day) .toLatin1 (); p.closeWriteChannel () P.waitForFinished (1000); p.close (); p.start ("cmd"); p.waitForStarted (); p.write (QString ("time% 1% cmd% 2 cmd% 3.00\ n") .Arg (hour) .arg (min) .arg (sec). ToLatin1 (); p.closeWriteChannel (); p.waitForFinished (1000); p.close () # else QString cmd = QString ("date% 1% 2% 4% 5.% 6") .arg (month) .arg (day) .arg (hour) .arg (min) .arg (year) .arg (sec); system (cmd.toLatin1 ()); system ("hwclock-w") # endif} void QUIHelper::runWithSystem (const QString & strName, const QString & strPath, bool autoRun) {# ifdef Q_OS_WIN QSettings reg ("HKEY_LOCAL_MACHINE\\ SOFTWARE\\ Microsoft\\ Windows\\ CurrentVersion\ Run", QSettings::NativeFormat); reg.setValue (strName, autoRun? StrPath: "); # endif} at this point, the study on" the general method of Qt and how to use the class library "is over. I hope I can solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.