What is you do?
If you want to change tool button icon when mouse over
you can use this code :
icon
->addPixmap
(QPixmap(":/Images/normal"));
action->setIcon(*icon));
QIcon* icon = new QIcon;
icon->addPixmap(QPixmap(":/Images/normal"));
icon->addPixmap(QPixmap(":/Images/hover", QIcon::Active));
action->setIcon(*icon));
To copy to clipboard, switch view to plain text mode
but you have to change icon in detail about mouse event,
I recommend you that using event filter.
before I know Qicon's function.. I tryed this method :
toolbar->installEventFilter(this);
bool hvMenuToolbarManager
::eventFilter( QObject *obj,
QEvent* e
) {
switch( e->type() )
{
pos = static_cast<QHoverEvent*>(e)->pos();
action = static_cast<QToolBar*>(obj)->actionAt(pos);
if(action)
{
action
->setIcon
(QIcon(":/Images/toolbar_icon"));
}
return true;
default:;
}
return QObject::eventFilter(obj, e
);
}
toolbar->installEventFilter(this);
bool hvMenuToolbarManager::eventFilter( QObject *obj, QEvent* e )
{
QAction* action;
QPoint pos;
switch( e->type() )
{
case QEvent::HoverMove:
pos = static_cast<QHoverEvent*>(e)->pos();
action = static_cast<QToolBar*>(obj)->actionAt(pos);
if(action)
{
action->setIcon(QIcon(":/Images/toolbar_icon"));
}
return true;
default:;
}
return QObject::eventFilter(obj, e);
}
To copy to clipboard, switch view to plain text mode
Of course, this code is not perfect, but it will be valuable attempt to you..
and sadly, I don't know how to using stylesheet to toolbutton made by qactions... SORRY..
Bookmarks