QLabel#m_icon{border-image:url(:/res/haiyang.png);/*图片路径*/min-width:40px;/*最小宽度*/min-height:40px;/*最小高度*/max-width:40px;/*最大宽度*/max-height:40px;/*最大高度*/background-position:center;/*居中显示*/background->attachment:fixed;/*固定*/background-repeat:repeat-n;/...
background-position为设置背景图片显示位置,只支持 left right top bottom center;值 left right center 为设置水平位置,值 top bottom center 为设置垂直位置 background为设置背景的所有属性,color image repeat position 这些属性值出现的顺序可以任意 下面是一个综合示例 QLabel { font-family: "Microsoft YaHei"...
void ButtonGroup::initCheckBoxGroup() { QButtonGroup* pButtonGroup =new QButtonGroup(this); pButtonGroup->addButton(ui.checkBox,1); pButtonGroup->addButto...Qt Label控件使用 Qt用Lable标签显示图片 1. 通过QtCreater设计器添加一个Lable控件 2. 在项目根目录下添加一个文件夹(名字随意) 3. 在...
以QLabel为例看看如何使用qss设置窗口的背景图片 1. 首先准备一张图片:2. 设置背景设置background-image:可以看到背景图片设置成功了,不过此时的背景图片是由设置的图片重复拼接而成的。3. 去重复设置background-repeat为no-repeat:背景图片默认位置在左上角。4. 设置背景图片的位置background-position:background-...
1>QPushButton和QToolButton QPushButton和QToolButton是Qt中常用的按钮控件,可以通过添加qss样式表来自定义按钮的外观。以下是一些常用的qss样式: 1.修改按钮的背景颜色和文字颜色: QPushButton { background-color: #4682b4; color: white; } 2.修改按钮的边框样式和边框颜色: ...
26 QPushButton *m_bu; 27 private slots: 28 void on_bu(); 29 private: 30 char* setstr(char *s); 31 private: 32 Ui::MainWindow *ui; 33 QPixmap pixmapToShow; 34 QPixmap pixmapToShow2; 35 QPixmap pixmapToShow3; 36 };
QPainterpainter(this); painter.drawPixmap(this->rect(),pixmap); } 三、QSS(样式表)设置背景 1)设置背景颜色 MainWin::MainWin() { this->setStyleSheet(" color: rgb(102, 102, 0);">); iLabel=newQLabel(this); iLabel->setStyleSheet(" color: rgb(102, 102, 0);">); ...
2)设置背景图片 MainWin::MainWin() { this->setStyleSheet("background-image:url(:/bmp/IMG_0345.JPG)"); iLabel = new QLabel(this); iLabel->setStyleSheet("background-image:url(:/bmp/1257253475842.jpg)"); } --- 注意: (1)以上都是用scaled方式对图片进行了适应窗口大小的设置,因为所给的图...
1.QLabel {border-width: 1px }/* 1px 1px 1px 1px */当输入一个值如 1px 则默认 QLable 的四个方向的值 都为 1px。此时是 right 默认用 top 的值, bottom 自动用 top 的值, right 自动用 right 的2.QLabel {border-width: 1px 2px } /* 1px 2px 1px 2px */输入两个值则表示 bottom 值...