This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Qt类中配置文件的读取之QSettings类 | |
| QSettings是qt4.0提供的一个读取配置文件的类, | |
| 在windows平台,它提供了ini文件读些,注册表读写的功能。而且使用也非常简单。 | |
| 在Qt开发中用QSettings类来读取整个系统的配置信息数据非常的好用。 | |
| 例如用QSetting来读取 app。ini文件中内容,appini信息如下: | |
| [User] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <io.h> | |
| #include <conio.h> | |
| #include <fcntl.h> | |
| #include <windows.h> | |
| #ifdef _DEBUG | |
| AllocConsole(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| QTextCodec::setCodecForLocale(QTextCodec::codecForName("GB2312")); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| qss对QLabel不起作用的解决方法: | |
| this->setBackgroundRole(QPalette::Dark); | |
| 具体原因未知,怀疑为setStyleSheet和QPalette冲突 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int main(int argc, char *argv[]) | |
| { | |
| QApplication app(argc,argv); | |
| QFrame *frame = new QFrame; | |
| frame->resize(400,700); | |
| QImage image1; | |
| image1.load("images/frame1.jpg"); | |
| QImage image2 = image1.scaled(400,700); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| QString name = qgetenv("USERNAME"); | |
| qDebug() << "User Name:" << name; | |
| //QHostInfo类作用,获取主机名,也可以通过主机名来查找IP地址,或者通过IP地址来反向查找主机名。 | |
| QString localHostName = QHostInfo::localHostName(); | |
| qDebug() << "LocalHostName:" << localHostName; | |
| //获取所有网络接口的列表 | |
| foreach(QNetworkInterface netInterface, QNetworkInterface::allInterfaces()) | |
| { | |
| //设备名 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .arg(static_cast<double>(tickItem.CurrentPrice / 100), 0, 'f', 2) | |
| QString::number(total_totalTurnover, 'f', 2) | |
| QSqlTableModel显示科学计数法的解决办法:重写虚函数data() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 编译成64位版本,全用qt5.5_64的dll。 |