void setcolormark(QRgb colorval) { int i; if (colorval != DEFAULTCOLOR) { i = 3 + colorlist.indexOf(colorval); if (i<3) return; // no such color :( } else { i = 2; // index of the "Inherit Color" action } // 1. mark the color in the menu toggleexcl(menuAction("Elements_Color")->menu()->actions()[i]); // 2. mark the color on the toolbar QAbstractButton *button = toolbar->findChild<QAbstractButton*>("Colors"); int toolIndex = button->property("index").toInt(); QImage img(ToolBar[toolIndex].icon_data); QPixmap pix(img.size()); QPainter p(&pix); if (i==2) { // inherit color -- default pixmap p.drawImage(0, 0, img); } else { // color pixmap p.fillRect(img.rect(), QColor(colorval)); } button->actions().first()->setIcon(QIcon(pix)); }