设置应用程序图标
在资源文件(*.res)中添加图标文件
资源文件代码如下:
在setupUi函数中添加相应代码
代码如下:
//set icon
QIcon icon;
icon.addPixmap(QPixmap(QString::fromUtf8(":/bmp/logo.png")),QIcon::Normal,
QIcon::Off);
WndTest->setWindowIcon(icon);
WndTest->setIconSize(QSize(256, 256));
在程序中显示图片(QLabel)
在程序的相应位置中添加相应代码
代码如下:
QLabel *lLogo;
lLogo = new QLabel();
lLogo->setObjectName(QString::fromUtf8(“lLogo”));
lLogo->setGeometry(QRect(160, 110, 128, 128));
lLogo->setPixmap(QPixmap(QString::fromUtf8(":/bmp/logo.png")));
lLogo->setScaledContents(true);
字体更改
QFont font;
font.setPointSize(40);
font.setBold(true);
font.setWeight(75);
QLabel *lfontnew = new QLabel();
lfontnew->setFont(font);
获取屏幕或工作区大小
#include
//获取屏幕分辨率第一种方法
qDebug()<< “screen width