一、概述
做一个好看的QRadioButton。可以选中,取消选中。
二、代码示例
1.样式
QRadioButton::indicator::unchecked { border-image: url(images/user_protocol_uncheck.webp); } QRadioButton::indicator::checked { border-image: url(images/user_protocol_checked.webp); } QRadioButton::indicator { width: 24px; height: 24px; }
2.自定义RadioButton.h/RadioButton.cpp
#include "RadioButton.h" RadioButton::RadioButton(QWidget *parent) : QRadioButton(parent) { //这里设置一个默认的样式 QString css = StyleHelper::getStyleSheet(StyleConfig::COMMON_RADIOBUTTON_DEFAULT()); this->setStyleSheet(css); } RadioButton::~RadioButton() { }
3.使用
//RadioButton RadioButton* rb = new RadioButton(); rb->move(5, et3->y() + et3->height() + 5);
4.效果
标签:indicator,protocol,Qt,自定义,样式,RadioButton,QRadioButton From: https://www.cnblogs.com/tony-yang-flutter/p/17862510.html