怎么设置QPushButton样式表
1个回答
2016-08-08
展开全部
QT中使用setStyleSheet()设置空间的样式表是很常用也很方便的方式。使用方法如下
工具/原料
QT开发工具
方法/步骤
首先要定义一个QPushButton对象
QPushButton button = new QPushButton();
设置button的字体类型、字体大小和字体颜色代码如下:
button->setStyleSheet"QPushButton{ font-family:'Microsoft YaHei';font-size:12px;color:#666666;}");
设置button的状态图片:正常、鼠标移入、鼠标点击状态的图片切换。代码如下:
button->setStyleSheet( "QPushButton{border-image: url(Resources/images/BreadCrumbNavigation/navigation_more_normal.png);}" "QPushButton:hover{border-image: url(Resources/images/BreadCrumbNavigation/navigation_more_hover.png);}" "QPushButton:pressed{border-image: url(Resources/images/BreadCrumbNavigation/navigation_more_pressed.png);}");
也可以同时设置这两种属性:
button->setStyleSheet( "QPushButton{font-family:'Microsoft YaHei';font-size:12px;color:#666666;}”
border-image: url(Resources/images/BreadCrumbNavigation/navigation_more_normal.png);}" "QPushButton:hover{border-image: url(Resources/images/BreadCrumbNavigation/navigation_more_hover.png);}" "QPushButton:pressed{border-image: url(Resources/images/BreadCrumbNavigation/navigation_more_pressed.png);}");
工具/原料
QT开发工具
方法/步骤
首先要定义一个QPushButton对象
QPushButton button = new QPushButton();
设置button的字体类型、字体大小和字体颜色代码如下:
button->setStyleSheet"QPushButton{ font-family:'Microsoft YaHei';font-size:12px;color:#666666;}");
设置button的状态图片:正常、鼠标移入、鼠标点击状态的图片切换。代码如下:
button->setStyleSheet( "QPushButton{border-image: url(Resources/images/BreadCrumbNavigation/navigation_more_normal.png);}" "QPushButton:hover{border-image: url(Resources/images/BreadCrumbNavigation/navigation_more_hover.png);}" "QPushButton:pressed{border-image: url(Resources/images/BreadCrumbNavigation/navigation_more_pressed.png);}");
也可以同时设置这两种属性:
button->setStyleSheet( "QPushButton{font-family:'Microsoft YaHei';font-size:12px;color:#666666;}”
border-image: url(Resources/images/BreadCrumbNavigation/navigation_more_normal.png);}" "QPushButton:hover{border-image: url(Resources/images/BreadCrumbNavigation/navigation_more_hover.png);}" "QPushButton:pressed{border-image: url(Resources/images/BreadCrumbNavigation/navigation_more_pressed.png);}");
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询