将鼠标悬停在QToolButton操作上时会显示警告

时间:2014-12-06 12:28:25

标签: c++ qt qt4 qaction

我做了一个QToolButton,其行为如下:

QToolButton * toolBut1 = new QToolButton(this);

actionGroup1 = new QActionGroup(this);
actionGroup1->setExclusive(true);

action1 = new QAction(QIcon(":/images/icon1"),"", actionGroup1);
action1->setCheckable(true);

action2 = new QAction(QIcon(":/images/icon2"),"", actionGroup1);
action2->setCheckable(true);

action3 = new QAction(QIcon(":/images/icon3"),"", actionGroup1);
action3->setCheckable(true);

toolBut1->addAction(action1);
toolBut1->addAction(action2);
toolBut1->addAction(action3);

但是当我将鼠标指针悬停在操作上时,应用程序输出中会显示一些警告:

  

QGradient :: setColorAt:颜色位置必须在0到1

的范围内指定

为什么会这样?如何解决?

P.S。我在Windows 7上使用Qt 4.8.4。

1 个答案:

答案 0 :(得分:0)

我为这些操作设置了不同的名称,结果是警告不再显示。

QToolButton * toolBut1 = new QToolButton(this);

actionGroup1 = new QActionGroup(this);
actionGroup1->setExclusive(true);

action1 = new QAction(QIcon(":/images/icon1"),"act1", actionGroup1);
action1->setCheckable(true);

action2 = new QAction(QIcon(":/images/icon2"),"act2", actionGroup1);
action2->setCheckable(true);

action3 = new QAction(QIcon(":/images/icon3"),"act3", actionGroup1);
action3->setCheckable(true);

toolBut1->addAction(action1);
toolBut1->addAction(action2);
toolBut1->addAction(action3);