QT窗口(7)-QColorDiag
QT窗口(7)-QColorDiag
引入新的函数 getcolor
代码如下:
QColor color=QColorDialog::getColor(QColor(0,255,0),this,"选择颜色");qDebug()<<color;
运行结果:
设置背景色:
代码如下:
QString style="background-color:rgb(" +QString::number(color.red())+","+QString::number(color.green())+","+QString::number(color.blue())+");";this->setStyleSheet(style);
写法二:
char style[1024]={0};sprintf(style,"background-color:rgb(%d,%d,%d);",color.red(),color.green(),color.blue());this->setStyleSheet(style);