本文整理汇总了C++中QAction::iconSet方法的典型用法代码示例。如果您正苦于以下问题:C++ QAction::iconSet方法的具体用法?C++ QAction::iconSet怎么用?C++ QAction::iconSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAction
的用法示例。
在下文中一共展示了QAction::iconSet方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setFormWindow
void ActionEditor::setFormWindow( FormWindow *fw )
{
listActions->clear();
formWindow = fw;
if ( !formWindow ||
!::qt_cast<QMainWindow*>(formWindow->mainContainer()) ) {
setEnabled( FALSE );
} else {
setEnabled( TRUE );
for ( QAction *a = formWindow->actionList().first(); a; a = formWindow->actionList().next() ) {
ActionItem *i = 0;
if ( ::qt_cast<QAction*>(a->parent()) )
continue;
i = new ActionItem( listActions, a );
i->setText( 0, a->name() );
i->setPixmap( 0, a->iconSet().pixmap() );
// make sure we don't duplicate the connection
QObject::disconnect( a, SIGNAL( destroyed( QObject * ) ),
this, SLOT( removeConnections( QObject * ) ) );
QObject::connect( a, SIGNAL( destroyed( QObject * ) ),
this, SLOT( removeConnections( QObject* ) ) );
if ( ::qt_cast<QActionGroup*>(a) ) {
insertChildActions( i );
}
}
if ( listActions->firstChild() ) {
listActions->setCurrentItem( listActions->firstChild() );
listActions->setSelected( listActions->firstChild(), TRUE );
}
}
}
示例2: contentsSize
QSize PopupMenuEditor::contentsSize()
{
QRect textRect = fontMetrics().boundingRect( addSeparator.action()->menuText() );
textWidth = textRect.width();
accelWidth = textRect.height(); // default size
iconWidth = textRect.height();
int w = 0;
int h = itemHeight( &addItem ) + itemHeight( &addSeparator );
PopupMenuEditorItem * i = itemList.first();
QAction * a = 0;
while ( i ) {
if ( i->isVisible() ) {
if ( !i->isSeparator() ) {
a = i->action();
w = a->iconSet().pixmap( QIconSet::Automatic, QIconSet::Normal ).rect().width() +
borderSize; // padding
iconWidth = QMAX( iconWidth, w );
w = fontMetrics().boundingRect( a->menuText() ).width();
textWidth = QMAX( textWidth, w );
w = fontMetrics().boundingRect( a->accel() ).width() + 2; // added padding?
accelWidth = QMAX( accelWidth, w );
}
h += itemHeight( i );
}
i = itemList.next();
}
int width = iconWidth + textWidth + borderSize * 3 + accelWidth + arrowWidth;
return QSize( width, h );
}
示例3: itemHeight
int PopupMenuEditor::itemHeight( const PopupMenuEditorItem * item ) const
{
if ( !item || ( item && !item->isVisible() ) )
return 0;
if ( item->isSeparator() )
return 4; // FIXME: hardcoded ( get from styles )r
int padding = + borderSize * 6;
QAction * a = item->action();
int h = a->iconSet().pixmap( QIconSet::Automatic, QIconSet::Normal ).rect().height();
h = QMAX( h, fontMetrics().boundingRect( a->menuText() ).height() + padding );
h = QMAX( h, fontMetrics().boundingRect( a->accel() ).height() + padding );
return h;
}
示例4: buttonMouseMoveEvent
void QDesignerToolBar::buttonMouseMoveEvent( QMouseEvent *e, QObject *o )
{
if ( widgetInserting || ( e->state() & LeftButton ) == 0 )
return;
if ( QABS( QPoint( dragStartPos - e->pos() ).manhattanLength() ) < QApplication::startDragDistance() )
return;
QMap<QWidget*, QAction*>::Iterator it = actionMap.find( (QWidget*)o );
if ( it == actionMap.end() )
return;
QAction *a = *it;
if ( !a )
return;
int index = actionList.find( a );
RemoveActionFromToolBarCommand *cmd =
new RemoveActionFromToolBarCommand( tr( "Delete Action '%1' from Toolbar '%2'" ).
arg( a->name() ).arg( caption() ),
formWindow, a, this, index );
formWindow->commandHistory()->addCommand( cmd );
cmd->execute();
QApplication::sendPostedEvents();
adjustSize();
QString type = ::qt_cast<QActionGroup*>(a) ? QString( "application/x-designer-actiongroup" ) :
::qt_cast<QSeparatorAction*>(a) ? QString( "application/x-designer-separator" ) : QString( "application/x-designer-actions" );
QStoredDrag *drag = new QStoredDrag( type, this );
QString s = QString::number( (long)a ); // #### huha, that is evil
drag->setEncodedData( QCString( s.latin1() ) );
drag->setPixmap( a->iconSet().pixmap() );
if ( ::qt_cast<QDesignerAction*>(a) ) {
if ( formWindow->widgets()->find( ( (QDesignerAction*)a )->widget() ) )
formWindow->selectWidget( ( (QDesignerAction*)a )->widget(), FALSE );
}
if ( !drag->drag() ) {
AddActionToToolBarCommand *cmd = new AddActionToToolBarCommand( tr( "Add Action '%1' to Toolbar '%2'" ).
arg( a->name() ).arg( caption() ),
formWindow, a, this, index );
formWindow->commandHistory()->addCommand( cmd );
cmd->execute();
}
lastIndicatorPos = QPoint( -1, -1 );
indicator->hide();
}
示例5: insertChildActions
void ActionEditor::insertChildActions( ActionItem *i )
{
if ( !i->actionGroup() || !i->actionGroup()->children() )
return;
QObjectListIt it( *i->actionGroup()->children() );
while ( it.current() ) {
QObject *o = it.current();
++it;
if ( !::qt_cast<QAction*>(o) )
continue;
QAction *a = (QAction*)o;
ActionItem *i2 = new ActionItem( (QListViewItem*)i, a );
i->setOpen( TRUE );
i2->setText( 0, a->name() );
i2->setPixmap( 0, a->iconSet().pixmap() );
// make sure we don't duplicate the connection
QObject::disconnect( o, SIGNAL( destroyed( QObject * ) ),
this, SLOT( removeConnections( QObject * ) ) );
QObject::connect( o, SIGNAL( destroyed( QObject * ) ),
this, SLOT( removeConnections( QObject * ) ) );
if ( ::qt_cast<QActionGroup*>(a) )
insertChildActions( i2 );
}
}
示例6: QMainWindow
ApplicationWindow::ApplicationWindow()
: QMainWindow( 0, "example application main window", WDestructiveClose )
{
#ifndef QT_NO_PRINTER
printer = new QPrinter( QPrinter::HighResolution );
#endif
QAction * fileNewAction;
QAction * fileOpenAction;
QAction * fileSaveAction, * fileSaveAsAction, * filePrintAction;
QAction * fileCloseAction, * fileQuitAction;
fileNewAction = new QAction( "&New", CTRL+Key_N, this, "new" );
connect( fileNewAction, SIGNAL( activated() ) , this,
SLOT( newDoc() ) );
fileOpenAction = new QAction( QPixmap( fileopen ), "&Open...",
CTRL+Key_O, this, "open" );
connect( fileOpenAction, SIGNAL( activated() ) , this, SLOT( choose() ) );
const char * fileOpenText = "<p><img source=\"fileopen\"> "
"Click this button to open a <em>new file</em>. <br>"
"You can also select the <b>Open</b> command "
"from the <b>File</b> menu.</p>";
QMimeSourceFactory::defaultFactory()->setPixmap( "fileopen",
fileOpenAction->iconSet().pixmap() );
fileOpenAction->setWhatsThis( fileOpenText );
fileSaveAction = new QAction( QPixmap( filesave ),
"&Save", CTRL+Key_S, this, "save" );
connect( fileSaveAction, SIGNAL( activated() ) , this, SLOT( save() ) );
const char * fileSaveText = "<p>Click this button to save the file you "
"are editing. You will be prompted for a file name.\n"
"You can also select the <b>Save</b> command "
"from the <b>File</b> menu.</p>";
fileSaveAction->setWhatsThis( fileSaveText );
fileSaveAsAction = new QAction( "Save File As", "Save &As...", 0, this,
"save as" );
connect( fileSaveAsAction, SIGNAL( activated() ) , this,
SLOT( saveAs() ) );
fileSaveAsAction->setWhatsThis( fileSaveText );
#ifndef QT_NO_PRINTER
filePrintAction = new QAction( "Print File", QPixmap( fileprint ),
"&Print...", CTRL+Key_P, this, "print" );
connect( filePrintAction, SIGNAL( activated() ) , this,
SLOT( print() ) );
const char * filePrintText = "Click this button to print the file you "
"are editing.\n You can also select the Print "
"command from the File menu.";
filePrintAction->setWhatsThis( filePrintText );
#else
Q_UNUSED( filePrintAction )
#endif
fileCloseAction = new QAction( "Close", "&Close", CTRL+Key_W, this,
"close" );
connect( fileCloseAction, SIGNAL( activated() ) , this,
SLOT( close() ) );
fileQuitAction = new QAction( "Quit", "&Quit", CTRL+Key_Q, this,
"quit" );
connect( fileQuitAction, SIGNAL( activated() ) , qApp,
SLOT( closeAllWindows() ) );
// populate a tool bar with some actions
QToolBar * fileTools = new QToolBar( this, "file operations" );
fileTools->setLabel( "File Operations" );
fileOpenAction->addTo( fileTools );
fileSaveAction->addTo( fileTools );
#ifndef QT_NO_PRINTER
filePrintAction->addTo( fileTools );
#endif
(void)QWhatsThis::whatsThisButton( fileTools );
// populate a menu with all actions
QPopupMenu * file = new QPopupMenu( this );
menuBar()->insertItem( "&File", file );
fileNewAction->addTo( file );
fileOpenAction->addTo( file );
fileSaveAction->addTo( file );
fileSaveAsAction->addTo( file );
#ifndef QT_NO_PRINTER
file->insertSeparator();
filePrintAction->addTo( file );
#endif
file->insertSeparator();
fileCloseAction->addTo( file );
fileQuitAction->addTo( file );
menuBar()->insertSeparator();
// add a help menu
//.........这里部分代码省略.........