怎样设置Qpushbutton 的大小
2个回答
2015-08-07 · 知道合伙人数码行家
关注
展开全部
首先要定义一个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);}");
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);}");
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询