colordialog.cpp
来自「一大堆的qt程序,在qte2.3.7下全部可以很好地运行」· C++ 代码 · 共 47 行
CPP
47 行
#include "colordialog.h"ColorDialog::ColorDialog(QWidget *parent,const char *name, bool isModal) :QDialog(parent,name,isModal){ redButton = new QPushButton("red",this); redButton->setGeometry(1,1,90,30); greenButton = new QPushButton("green",this); greenButton->setGeometry(1,31,90,30); blueButton = new QPushButton("blue",this); blueButton->setGeometry(1,61,90,30); whiteButton = new QPushButton("white",this); whiteButton->setGeometry(1,91,90,30); connect(redButton,SIGNAL(pressed()),SLOT(chooseColor())); connect(greenButton,SIGNAL(pressed()),SLOT(chooseColor())); connect(blueButton,SIGNAL(pressed()),SLOT(chooseColor())); connect(whiteButton,SIGNAL(pressed()),SLOT(chooseColor()));}void ColorDialog:: chooseColor(){ if(redButton->isDown()) { col = red; } else if(greenButton->isDown()) { col = green; } else if(blueButton->isDown()) { col = blue; } else if(whiteButton->isDown()) { col = white; } this->close();}QColor ColorDialog:: color(){ return col;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?