0

我做了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的范围内指定

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

PS 我在 Windows 7 上使用 Qt 4.8.4。

4

1 回答 1

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);
于 2014-12-18T07:51:04.107 回答