打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Qt杂项设置(QLabel超链接、图片缩放、窗口不在任务栏显示并置顶等)
转:http://www.bubuko.com/infodetail-416111.html

1.使用代码设置渐变

QLinearGradient linearGrad(QPointF(0, 0), QPointF(200, 200));linearGrad.setColorAt(0, Qt::blue);linearGrad.setColorAt(1, Qt::white);linearGrad.setCoordinateMode(QGradient::StretchToDeviceMode);QBrush brush(linearGrad);item1->setBackground(brush);

2.QPixmap图片的缩放

Qsize picSize(600,400);//将pixmap缩放成picSize大小然后保存在scaledPixmap中按比例缩放:QPixmap scaledPixmap = pixmap.scaled(picSize, Qt::KeepAspectRatio);不按照比例缩放QPixmap scaledPixmap = pixmap.scaled(picSize);

3.设置窗口不在任务栏显示并置顶

setWindowFlags(Qt::Tool | Qt::X11BypassWindowManagerHint | Qt::WindowStaysOnTopHint);

4.QLineEdit去掉右键菜单

_ui->_passwordEdit->setContextMenuPolicy(Qt::NoContextMenu);//去掉右键菜单

5.去除QString中的空格

QString str = "  lots\t of\nwhitespace\r\n "; str = str.trimmed(); // str == "lots\t of\nwhitespace" QString str = "  lots\t of\nwhitespace\r\n "; str = str.simplified(); // str == "lots of whitespace";

6.QLabel实现超链接

ui->_userWebConnect->setOpenExternalLinks(true);ui->_userWebConnect->setText("<a href = \"http://zkuyun.com/\>显示的内容</a>");

 7.QTreeView去掉父节点的下拉

treeView->setRootIsDecorated(false);// UI控件里,在右边的设置属性里找到 QTreeView那栏,将rootIs Decorated 复选框,不要勾选

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
qt控件的使用
QLabel
Qt-4.6动画Animation快速入门三字决
Qt可显示的图像类型
(转载)基于ZedBoard的Webcam设计(三):视频的采集和动态显示
QPushButton && QLabel
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服