这个东西就是楼主要的,很像很像,特别特别像。甚至更简单一些。
代码看起来像:
#include <QtGui>
int main(int argc, char *argv[])
{
QApplication a(argc, argv)//程序
QWidget w//一个窗口
QPushButton *pb=new QPushButton("I'm a QPushButton",&w)//一个按钮在窗口w里面
QObject::connect(pb,SIGNAL(clicked()),&a,SLOT(quit()))//点按钮关程序,有空的话可以用Action
w.show()//显示窗口
return a.exec()//执行
}
其他楼主看说明吧,取值、设字体什么的基本上也很像
1. 点#include<GRAPHICS.H>
main()
{
int graphdriver=CGA
int graphmode=CGAC0,x
initgraph(&graphdriver,&graphmode," ")
cleardevice()
for (x=20x<=300x+=16)
{
putpixel(x,20,1)
putpixel(x+4,20,2)
}
getch()
closegraph()
}
2. 直线
#include<GRAPHICS.H>
void linedda(int x0,int y0,int x1,int y1,int color)
{
int x,dy,dx,y
float m
dx=x1-x0
dy=y1-y0
m=dy/dx
y=y0
for (x=x0x<=x1x++)
{
putpixel(x,(int)(y+0.5),color)
y+=m
}
}
main()
{
int a,b,c,d,e
int graphdriver=DETECT
int graphmode=0
initgraph(&graphdriver,&graphmode," ")
cleardevice()
a=0
b=0
c=200
d=300
e=2
linedda(a,b,c,d,e)
getch()
closegraph()
}
3. 圆
#include<GRAPHICS.H>
void circlepoints(int x,int y,int color)
{int m,n, xasp,yasp
float aspectratio
m=200 n=200
getaspectratio(&xasp,&yasp)
aspectratio=xasp/yasp
putpixel(x+m,y*aspectratio+n,color)
putpixel(y+m,x*aspectratio+n,color)
putpixel(-y+m,x*aspectratio+n,color)
putpixel(-x+m,y*aspectratio+n,color)
putpixel(y+m,-x*aspectratio+n,color)
putpixel(x+m,-y*aspectratio+n,color)
putpixel(-x+m,-y*aspectratio+n,color)
putpixel(-y+m,-x*aspectratio+n,color)
}
void midpointcircle(int r,int c)
{ int x,y
float d
x=0 y=r d=5.0/4-r
circlepoints(x,y,c)
while(y>x)
{if(d<=0)
d+=2.0*x+3
else
{d+=2.0*(x-y)+5
y--
}
x++
circlepoints(x,y,c)
}
}
main()
{int a,b
int graphdriver=DETECT
int graphmode=0
initgraph(&graphdriver,&graphmode," ")
cleardevice()
a=200 b=2
midpointcircle(a,b)
getch()
closegraph()
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)