groovy 方式写的qt时钟代码

groovy 方式写的qt时钟代码,第1张

概述groovy 方式 写的qt时钟代码

下面是内存溢出 jb51.cc 通过网络收集整理的代码片段。

内存溢出小编现在分享给大家,也给大家做个参考。

/** *  */package com.suziwenimport com.trolltech.qt.core.QPointimport com.trolltech.qt.core.QTimeimport com.trolltech.qt.core.QTimerimport com.trolltech.qt.gui.QApplicationimport com.trolltech.qt.gui.Qcolorimport com.trolltech.qt.gui.QHIDeEventimport com.trolltech.qt.gui.QPaintEventimport com.trolltech.qt.gui.QPainterimport com.trolltech.qt.gui.QPenimport com.trolltech.qt.gui.Qpolygonimport com.trolltech.qt.gui.QShowEventimport com.trolltech.qt.gui.QWidget/** * @author suziwen * */class Clock extends QWidget {	QTimer qtimer = new QTimer();		static def hourHand = new Qpolygon([new QPoint(7,8),new QPoint(-7,new QPoint(0,-30)]);	static def minuteHand = new Qpolygon([new QPoint(7,-70)]);	static def secondHand = new Qpolygon([new QPoint(3,new QPoint(-3,-90)]);	static def hourcolor = new Qcolor(127,127);	static def minutecolor = new Qcolor(0,129,129);	static def secondcolor = new Qcolor(0,100,100);	Clock(){		super();		qtimer.timeout.connect(this,"update()");	}	voID hIDeEvent (QHIDeEvent event){		qtimer.stop();	}	voID showEvent(QShowEvent event){		qtimer.start(1000);	}	voID  paintEvent(QPaintEvent e){		def sIDe = Math.min(this.wIDth(),this.height());		def time = QTime.currentTime();		def painter = new QPainter(this);		painter.translate(this.wIDth()/2,this.height()/2);		painter.setRenderHint(QPainter.RenderHint.Antialiasing);		painter.scale(sIDe/200,sIDe/200);		painter.setPen(QPen.nopen);		painter.setBrush(hourcolor);		painter.save();		painter.rotate(30.0*(time.hour() + time.minute()/60.0));		painter.drawConvexpolygon(hourHand);		painter.restore();		painter.setPen(hourcolor);		for( def i in 0..12){			painter.drawline(0,92,96);			painter.rotate(30.0);		}		painter.setPen(QPen.nopen);		painter.setBrush(minutecolor);		painter.save();		painter.rotate(6.0*(time.minute() + time.second()/60.0));		painter.drawConvexpolygon(minuteHand);		painter.restore();		painter.setPen(minutecolor);		for(def i in 0..60){			if(i % 5 != 0 ){				painter.drawline(0,94,96);			}			painter.rotate(6.0);		}		painter.setPen(QPen.nopen);		painter.setBrush(secondcolor);		painter.save();		painter.rotate(6.0*time.second());		painter.drawConvexpolygon(secondHand);		painter.restore();	}	static main(args) {		QApplication app = new QApplication(args);		def clock = new Clock();		clock.resize(500,500);		clock.show();		app.exec();	}}

以上是内存溢出(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

总结

以上是内存溢出为你收集整理的groovy 方式 写的qt时钟代码全部内容,希望文章能够帮你解决groovy 方式 写的qt时钟代码所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1271945.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-08
下一篇 2022-06-08

发表评论

登录后才能评论

评论列表(0条)

保存