enBat = Toolbar->addAction( QIcon( ":/icons/enbat.png" ), tr( "En Bat" ) ); Toolbar->widgetForAction( enBat )->setObjectName( "enButton" ); connect( enBat, SIGNAL( toggled( bool ) ), this, SLOT( enToggled( bool ) ) );
enBat->setContextMenuPolicy( Qt::CustomContextMenu ); connect( enBat, SIGNAL( customContextMenuRequested( const QPoint & ) ), this, SLOT( context( const QPoint & ) ) );
scButton = new QToolButton( Toolbar ); scButton->setIcon( QIcon (":/icons/enbat.png") ); scButton->setPopupMode( QToolButton::InstantPopup ); scButton->addAction( enBat ); scButton->setContextMenuPolicy( Qt::CustomContextMenu ); Toolbar->addWidget(scButton); connect( scButton, SIGNAL( customContextMenuRequested( const QPoint & ) ), this, SLOT( context( const QPoint & ) ) );
scButton->setPopupMode( QToolButton::InstantPopup );
trayIconMenu.addAction( enBat );
connect( trayIconMenu.addAction( QIcon( ":/icons/enbat.png" ), tr( "En Bat" ) ), SIGNAL( triggered( bool )), this, SLOT( enToggled( bool ) ) );
Спасибо. Попробовал. Код для кнопки похудел: scButton = new QToolButton( navToolbar ); scButton ->setDefaultAction( enBat ); scButton ->setContextMenuPolicy( Qt::CustomContextMenu ); Toolbar->addWidget( scButton ); connect( scButton, SIGNAL( customContextMenuRequested( const QPoint & ) ), this, SLOT( context( const QPoint & ) ) );
enBat = Toolbar->addAction( QIcon( ":/icons/enbat.png" ), tr( "En Bat" ) );Toolbar->widgetForAction( enBat )->setObjectName( "enButton" ); connect( enBat, SIGNAL( toggled( bool ) ), this, SLOT( enToggled( bool ) ) );
QAction *enBat = new QAction(QIcon( ":/icons/enbat.png" ), tr( "En Bat" ));QToolButton *scButton = new QToolButton( navToolbar );scButton->setDefaultAction( enBat );scButton->setContextMenuPolicy( Qt::CustomContextMenu );Toolbar->addWidget( scButton );и т.д.
enBat = Toolbar->addAction( QIcon( ":/icons/enbat.png" ), tr( "En Bat" ) ); scButton = new QToolButton( Toolbar ); scButton->setDefaultAction( enBat ); Toolbar->addWidget( scButton );