📄 colordialog.cpp
字号:
#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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -