本文整理汇总了C++中QAction::accel方法的典型用法代码示例。如果您正苦于以下问题:C++ QAction::accel方法的具体用法?C++ QAction::accel怎么用?C++ QAction::accel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAction
的用法示例。
在下文中一共展示了QAction::accel方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 );
}
示例2: saveShortcuts
static void saveShortcuts(QTextStream &fout)
{
QPtrList<QAction> *actions;
QAction *action;
fout << "# all shortcuts \n";
actions = Shortcuts::actions();
for( action = actions->first(); action; action = actions->next() )
if(strlen(action->name()))
fout << "map(\"" << action->name() << "\", \"" << (QString)action->accel() << "\")\n";
}
示例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: setAccelerator
void PopupMenuEditor::setAccelerator( int key, Qt::ButtonState state, int index )
{
// FIXME: make this a command
int idx = ( index == -1 ? currentIndex : index );
if ( key == Qt::Key_Shift ||
key == Qt::Key_Control ||
key == Qt::Key_Alt ||
key == Qt::Key_Meta ||
key == Qt::Key_unknown )
return; // ignore these keys when they are pressed
PopupMenuEditorItem * i = 0;
if ( idx >= (int)itemList.count() )
i = createItem();
else
i = itemList.at( idx );
int shift = ( state & Qt::ShiftButton ? Qt::SHIFT : 0 );
int ctrl = ( state & Qt::ControlButton ? Qt::CTRL : 0 );
int alt = ( state & Qt::AltButton ? Qt::ALT : 0 );
int meta = ( state & Qt::MetaButton ? Qt::META : 0 );
QAction * a = i->action();
QKeySequence ks = a->accel();
int keys[4] = { ks[0], ks[1], ks[2], ks[3] };
int n = 0;
while ( n < 4 && ks[n++] );
n--;
if ( n < 4 )
keys[n] = key | shift | ctrl | alt | meta;
a->setAccel( QKeySequence( keys[0], keys[1], keys[2], keys[3] ) );
MetaDataBase::setPropertyChanged( a, "accel", TRUE );
resizeToContents();
}