⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 field.cpp

📁 一个多进程通信的演示
💻 CPP
字号:
#include <QDateTime>#include <QPaintEvent>#include <QPainter>#include <QTimer>#include <stdio.h>#include "field.h"extern "C"{	#include "connect.h"};extern "C"{	void setPos( int x, int y );};Field::Field( QWidget* parent )	:QWidget( parent ),	bTransSignal( false ){		timer = new QTimer(this);	timeCount = 0;		connect(timer, SIGNAL(timeout()), this, SLOT(move()));	xSpeed = 1;	ySpeed = 1;	posX = 200;	posY = 200;	radious = 25;			timer->start(6);	setPalette(QPalette(QColor(250, 250, 200)));    	setAutoFillBackground(true);}void Field::checkIfTouch(){	if( posX + radious > 1200 ||  posX - radious < 0  )		xSpeed = -xSpeed;	else if( posY + radious > 400 || posY - radious < 0 )		ySpeed = -ySpeed;}void Field::paintEvent( QPaintEvent* event )	{	QPainter painter(this);    	painter.setPen(Qt::NoPen);    	painter.setBrush(Qt::blue);	painter.drawRoundRect( posX- radious, posY - radious, 2*radious, 2*radious );} void Field::move(){	update( posX - radious, posY - radious, 2*radious, 2*radious );	checkIfTouch()	;	posX += xSpeed;	posY += ySpeed;		setPos( posX, posY );}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -