colordialog.cpp

来自「一大堆的qt程序,在qte2.3.7下全部可以很好地运行」· C++ 代码 · 共 68 行

CPP
68
字号
#include "colordialog.h"ColorDialog::ColorDialog(QWidget *parent,const char *name,bool isModal)		:QDialog(parent,name,isModal){	setCaption("Qt Colors");	int width = 90;	int height= 30;	int x = 1;	int y = 1;	col = white;	whiteButton = new QPushButton("white",this);//	whiteButton->setFlat(TRUE);	whiteButton->setBackgroundColor(white);	redButton = new QPushButton("red",this);//	redButton->setFlat(TRUE);	redButton->setBackgroundColor(red);	greenButton = new QPushButton("green",this);	greenButton->setFlat(TRUE);	greenButton->setBackgroundColor(green);	blueButton = new QPushButton("blue",this);	blueButton->setFlat(TRUE);	blueButton->setBackgroundColor(blue);	whiteButton->setGeometry(x,y,width,height);	redButton->setGeometry(x,(y+height),width,height);	greenButton->setGeometry(x,(y+height*2),width,height);	blueButton->setGeometry(x,(y+height*3),width,height);	connect(whiteButton,SIGNAL(pressed()),SLOT(chooseColor()));	connect(redButton,SIGNAL(pressed()),SLOT(chooseColor()));	connect(greenButton,SIGNAL(pressed()),SLOT(chooseColor()));	connect(blueButton,SIGNAL(pressed()),SLOT(chooseColor()));}void ColorDialog::chooseColor(){	if(whiteButton->isDown())	{		col = white;	}	else    if(redButton->isDown())		      	{			col = red;		}	else    if(greenButton->isDown())		{			col = green;		}	else	if(blueButton->isDown())		{			col = blue;		}	this->close();}QColor ColorDialog::color(){	return col;}

⌨️ 快捷键说明

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