|
void MainWindow::creatColorComboBox(QComboBox *comboBox)
{
QPixmap pix(16,16);
QPainter painter(&pix);
painter.fillRect(0,0,16,16,Qt::black); //先绘制一个16*16的小图片,然后给其涂色
comboBox->addItem(QIcon(pix),tr("黑色"),Qt::black); //再用该图片作为组合框条目的图标
painter.fillRect(0,0,16,16,Qt::white);
comboBox->addItem(QIcon(pix),tr("白色"),Qt::white);
painter.fillRect(0,0,16,16,Qt::red);
comboBox->addItem(QIcon(pix),tr("红色"),Qt::red);
painter.fillRect(0,0,16,16,Qt::green);
comboBox->addItem(QIcon(pix),tr("绿色"),Qt::green);
painter.fillRect(0,0,16,16,Qt::blue);
comboBox->addItem(QIcon(pix),tr("蓝色"),Qt::blue);
painter.fillRect(0,0,16,16,Qt::yellow);
comboBox->addItem(QIcon(pix),tr("黄色"),Qt::yellow);
comboBox->addItem(tr("无颜色"),Qt::transparent); //即透明
}这是该函数代码。已在头文件中对函数定义。提示的错误如下
C:\Qt\Qt5.3.1\5.3\mingw482_32\include\QtCore\qvariant.h:480: error: 'QVariant:Variant(Qt::GlobalColor)' is private
QVariant(Qt::GlobalColor) Q_DECL_EQ_DELETE;
^
D:\project\paint\mainwindow.cpp:241: error: within this context
comboBox->addItem(QIcon(pix),tr("榛戣壊"),Qt::black);
^
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
|