QToolButton设置图标及更改图标大小
QToolButton btn;
btn.setIconSize(QSize(35,35));//更改图标大小
btn.setIcon(QIcon(":/images/screen.png"));//设置图标
QToolButton设置图标和文字显示格式
格式类型:
enum ToolButtonStyle {
ToolButtonIconOnly, //只显示图标(默认)
ToolButtonTextOnly,//只显示文字
ToolButtonTextBesideIcon,//文字在图标右侧
ToolButtonTextUnderIcon,//文字在图标下面
ToolButtonFollowStyle
};
QToolButton btn;
btn.setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
抓取整个屏幕
QScreen *screen = QGuiApplication::primaryScreen();
QImage image = screen->grabWindow(0,0,0,-1,-1).toImage();//第一个参数为0,表示主屏幕
QLabel实现外部网页和本地路径超链接
外部网页链接
QLabel *label = new QLabel(this);
label->setOpenExternalLinks(true);
label->setText("<a style='color:blue; text-decoration: none' href = https://www.baidu.com>百度");//文字颜色为蓝色,无下划线
本地文件夹或者文件链接
链接前面加上file:///协议,解决本地路径中含有中文而访问失败的问题。
QLabel *label = new QLabel(this);
label->setOpenExternalLinks(true);
label->setText("<a href=\"file:///D:/images/11.jpg\">打开图片");