- 浏览: 762728 次
- 性别:
- 来自: 深圳
文章列表
发一个自己写的贪吃蛇,很烂,就当给以后留下点回忆吧,靠它赢了顿必胜客,哈哈
myt.h
#include <QtGui/QWidget>
#include "ui_myt.h"
#include "qpainter.h"
#include "QTimer"
#include "QPainterPath"
class MyT : public QWidget
{
Q_OBJECT
public:
MyT(QWidget *parent = 0, Qt::WFlags fla ...
QTimer* mTimer = new QTimer(this);
connect(mTimer,SIGNAL(timeout()),this,SLOT(move()));
mTimer->start(1000);//From then on, the move() slot is called every second.
一年前用它跑了个贪吃蛇,一年后用它做了下自动重连主机
由于qrand()得到的是固定的伪随机数,而time得到的如果在时间小于一秒则相差不大,要想每次运行程序生成的不一样,我的做法是把这两种相加,这样下次运行得到的多个随机数就和上次不一样了.
//random rect
QRectF randRect;
long randTimeNum = time(NULL);
randRectNum += RandomRect+mLevel*2;
for (int i=0;i<randRectNum;i++)
{
int randX = abs((qrand()+randTimeNum))%30;//0-29
i ...
QCheckBox *checkBox = qobject_cast<QCheckBox*>(sender())
//Russian的unicode
static const QChar unicode[] = {0x0420,0x0443,0x0441,0x0441,0x043A,0x0438,0x0439};
int size = sizeof(unicode) / sizeof(QChar);
QString str= QString::fromRawData(unicode, size);//Россию
QFontMetrics fm = painter->fontMetrics();
QPrinter *printer = new QPrinter;
mPixelPerCentimeter = printer->resolution()/2.54;
foreach(QString str,szTable)
{
double tempWidth = fm.width(str)/mPixelPerCentimeter;
width = qMax(tempWidth,width);
}
double height = fm.height()/mPixel ...
cat与more的区别
- 博客分类:
- Linux
cat:是一次显示完全,如果文件太大就跳到最下面了
more:是一次显示满当前屏幕,按回车显示下面的内容,按q退出
tac:是从最后一行开始显示完全(cat倒过来写就是tac了)
head:显示头几行
tail -n:显示前n行
je反馈http://javaeye-admin.group.iteye.com/
test.
etc/ld.so.conf.d
http://blog.csdn.net/sunnyboycao/article/details/6364444
http://www.linuxidc.com/Linux/2011-02/32535.htm
tcp
http://topic.csdn.net/u/20110729/12/f19b2011-a0cb-4407-8798-b163763313ac.html
http://www.qtcentre.org/threads/45386-QTcpSoc ...