当前位置:网站首页>QT self drawing button with bubbles
QT self drawing button with bubbles
2022-07-03 10:02:00 【Master Hao】
#include
#include
class QTipButton : public QPushButton
{
public:
QTipButton(QWidget *parent);
virtual ~QTipButton(void);
virtual void paintEvent(QPaintEvent * event);
void setButtonNum(int buttonNum);
private:
int _buttonNum=0;
};
#include “qtipbutton.h”
#include “qpainter.h”
#include “QRgb”
QTipButton::QTipButton(QWidget *parent)
: QPushButton(parent)
{
}
QTipButton::~QTipButton(void)
{
}
void QTipButton::paintEvent(QPaintEvent * event)
{
QPainter painter(this);
painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing);// Anti-Aliasing , Anti aliasing
QRect rt = rect();
QRect rt1 = QRect(rt.left()+rt.width()*0.70, (rt.top()+rt.height()*0.15), rt.height()*0.7, rt.height()*0.7);
QRect rt2 = QRect(rt.left(), rt.top(),
rt.width(), rt.height());
if(this->isChecked())
{
painter.fillRect(rt2, QColor(34,160,108));
painter.setPen(Qt::white);
painter.drawText(rt, Qt::AlignCenter, text());
}
else
{
painter.fillRect(rt2, QColor(71, 102, 92));
painter.setPen(Qt::white);
painter.drawText(rt, Qt::AlignCenter, text());
}
painter.setPen(QColor(163, 0, 20));
painter.setBrush(QBrush(Qt::red));
if( _buttonNum!=0)
{
painter.drawEllipse(rt1);
}
painter.setPen(Qt::white);
if( _buttonNum!=0)
{
painter.drawText(rt1, Qt::AlignCenter, QString::number(_buttonNum));
}
}
void QTipButton::setButtonNum(int buttonNum)
{
_buttonNum = buttonNum;
}

边栏推荐
- STM32 general timer output PWM control steering gear
- Emballage automatique et déballage compris? Quel est le principe?
- Interruption system of 51 single chip microcomputer
- A lottery like scissors, stone and cloth (C language)
- Stm32 NVIC interrupt priority management
- Idea remote breakpoint debugging jar package project
- Project scope management__ Scope management plan and scope specification
- Project cost management__ Topic of comprehensive calculation
- There is no specific definition of embedded system
- Timer and counter of 51 single chip microcomputer
猜你喜欢

Getting started with JMX, MBean, mxbean, mbeanserver

Embedded systems are inherently flawed. Compared with the Internet, there are so many holes that it is simply difficult to walk away from

Education is a pass and ticket. With it, you can step into a higher-level environment

Vector processor 9_ Basic multilevel interconnection network

学历是一张通行证,门票,你有了它,可以踏入更高层次的环境里

2. Elment UI date selector formatting problem

Notes on C language learning of migrant workers majoring in electronic information engineering

内存数据库究竟是如何发挥内存优势的?

My notes on intelligent charging pile development (II): overview of system hardware circuit design

GPIO port details, Hal library operation keys
随机推荐
一个可执行的二进制文件包含的不仅仅是机器指令
MySQL的简单使用(增删改查)
4G module designed by charging pile obtains signal strength and quality
STM32 external interrupt experiment
Seven sorting of ten thousand words by hand (code + dynamic diagram demonstration)
Gpiof6, 7, 8 configuration
2020-08-23
03 fastjason solves circular references
Project cost management__ Plan value_ Earned value_ Relationship among actual cost and Countermeasures
Stm32 NVIC interrupt priority management
Quelle langue choisir pour programmer un micro - ordinateur à puce unique
How does the memory database give full play to the advantages of memory?
Mobile phones are a kind of MCU, but the hardware it uses is not 51 chip
STM32 general timer output PWM control steering gear
Fundamentals of Electronic Technology (III)__ Chapter 1 resistance of parallel circuit
My notes on intelligent charging pile development (II): overview of system hardware circuit design
My 4G smart charging pile gateway design and development related articles
CEF download, compile project
01仿B站项目业务架构
Mysql database underlying foundation column