Qt - style custom cursor clicks

reason

     Last week, the right thumb caught the door of their own helpless hurt ,, ,, even forced to pull a surgery pain can not be issued, fasting and so cause a lot of inconvenience, hey bell firmly happy again. . Then even the mind of hand travel pesticides, and see friends also live broadcast ease. Notes that some of the effects manipulation software while recording the screen, so with this article. Pain makes me bitterly uneven, the current text code in many places less than satisfactory but still there is some things, like friends want to view. The recent focus on the content of the text direction surface.
     Next, continue. .

text

     Only one truth:
Here Insert Picture Description
     the above chart, color, width not cackle, picking up some of the more real to talk about the process. "Circle" effect is actually draws a circle, but the radius of the circle is gradually enlarged until it is large enough to disappear according to the time change, we have to do is control the radial expansion of mobile and location and nothing more. "Swastika text" special effects, then it is simple compared to that recorded the first click position and shape painting by location, point to note here is the transformation of coordinate positions and disappear with the end time is automatically increased in size. "Wen bomb" effects Well, hey skin is more than the two above, I began to initialize some string groups need time to randomly take over one of them, a record position in Kazakhstan click on this location to get out of the string, then by the location and time can move to disappear. Roughly understand the basic will win ko. Below the code. .

Ripple::Ripple(QWidget *parent /*= nullptr*/)
{
	mouseReleaseFlag = false;
	RippleValue = 0;

	MaxValue = 32;
	Width = 1;
	Color = Qt::black;
	tags << "hello,world!" << QString::fromLocal8Bit("拔甲大夫真tm兴奋。。") << QString::fromLocal8Bit("拔甲大夫真tm") << QString::fromLocal8Bit("青葱岁月。");
}

void Ripple::mouseReleaseEvent(QMouseEvent *event)
{
	if (!mouseReleaseFlag)
	{
		mouseReleaseFlag = true;
		mouseReleasePoint = event->pos();
		tag = tags[qrand() % tags.count()];
		TimerId = startTimer(100);
	}
}

void Ripple::paintEvent(QPaintEvent *event)
{
	QPen pen;
	pen.setColor(Color);
	pen.setWidth(Width);

	QFont font("微软雅黑", 12, QFont::Normal);

	QPainter painter(this);
	painter.setRenderHint(QPainter::Antialiasing);
	painter.setPen(pen);
	if (rippleStyle == Ripple::RippleStype::CircleSymbol)
	{
		painter.drawEllipse(mouseReleasePoint, RippleValue, RippleValue);
	}
	else if (rippleStyle == Ripple::RippleStype::WanSymbol)
	{
		if (RippleValue)
		{
			painter.save();
			painter.translate(mouseReleasePoint);
			painter.drawLine(0, 0, -RippleValue / 2, 0);
			painter.drawLine(-RippleValue / 2, 0, -RippleValue / 2, -RippleValue / 2);
			painter.drawLine(0, 0, RippleValue / 2, 0);
			painter.drawLine(RippleValue / 2, 0, RippleValue / 2, RippleValue / 2);
			painter.drawLine(0, 0, 0, -RippleValue / 2);
			painter.drawLine(0, -RippleValue / 2, RippleValue / 2, -RippleValue / 2);
			painter.drawLine(0, 0, 0, RippleValue / 2);
			painter.drawLine(0, RippleValue / 2, -RippleValue / 2, RippleValue / 2);
			painter.restore();
		}
	}
	else if (rippleStyle == Ripple::RippleStype::TagSymbol)
	{
		painter.save();
		painter.translate(mouseReleasePoint);
		painter.setFont(font);
		if(RippleValue)
			painter.drawText(0, -RippleValue, tag);
		painter.restore();
	}
}

Source

Source being uploaded, please wait. .

attention

Micro-channel public number search " Qt_io_ " or " Qt Developer Center " to learn more about the development of knowledge ..

I - jxd

Published 43 original articles · won praise 0 · Views 2998

Guess you like

Origin blog.csdn.net/automoblie0/article/details/102981764