本文整理汇总了C++中QActionGroup::addTo方法的典型用法代码示例。如果您正苦于以下问题:C++ QActionGroup::addTo方法的具体用法?C++ QActionGroup::addTo怎么用?C++ QActionGroup::addTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QActionGroup
的用法示例。
在下文中一共展示了QActionGroup::addTo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QMainWindow
Frame::Frame( QWidget *parent, const char *name )
: QMainWindow( parent, name )
{
QMenuBar *mainMenu = menuBar();
QPopupMenu *fileMenu = new QPopupMenu( this, "file" );
fileMenu->insertItem( tr( "&Exit" ), this, SLOT( close() ),
QAccel::stringToKey( tr( "Ctrl+Q" ) ) );
QPopupMenu *styleMenu = new QPopupMenu( this, "style" );
styleMenu->setCheckable( TRUE );
QActionGroup *ag = new QActionGroup( this, 0 );
ag->setExclusive( TRUE );
QSignalMapper *styleMapper = new QSignalMapper( this );
connect( styleMapper, SIGNAL( mapped( const QString& ) ),
this, SLOT( setStyle( const QString& ) ) );
QStringList list = QStyleFactory::keys();
list.sort();
QDict<int> stylesDict( 17, FALSE );
for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
QString style = *it;
QString styleAccel = style;
if ( stylesDict[styleAccel.left(1)] ) {
for ( uint i = 0; i < styleAccel.length(); i++ ) {
if ( !stylesDict[styleAccel.mid( i, 1 )] ) {
stylesDict.insert(styleAccel.mid( i, 1 ), (const int *)1);
styleAccel = styleAccel.insert( i, '&' );
break;
}
}
} else {
stylesDict.insert(styleAccel.left(1), (const int *)1);
styleAccel = "&"+styleAccel;
}
QAction *a = new QAction( style, QIconSet(),
styleAccel, 0, ag, 0, ag->isExclusive() );
connect( a, SIGNAL( activated() ), styleMapper, SLOT(map()) );
styleMapper->setMapping( a, a->text() );
}
ag->addTo( styleMenu );
mainMenu->insertItem( tr( "&File" ), fileMenu );
mainMenu->insertItem( tr( "St&yle" ), styleMenu );
stack = new QWidgetStack( this );
setCentralWidget( stack );
}
示例2: popupMarks
void FLConnectDBDialog::popupMarks()
{
QPopupMenu *marks = new QPopupMenu(this, "marks");
QActionGroup *ag = new QActionGroup(this, 0);
QSignalMapper *marksMapper = new QSignalMapper(this);
connect(marksMapper, SIGNAL(mapped(const QString &)), this, SLOT(tryConnectMark(const QString &)));
QStringList list;
for (int i = 0; i < comboBoxMarks->count(); i++)
list << comboBoxMarks->text(i);
list.sort();
QDict < int >marksDict(17, false);
for (QStringList::Iterator it = list.begin(); it != list.end(); ++it) {
QString marksStr = *it;
QString marksAccel = marksStr;
if (marksDict[ marksAccel.left(1)]) {
for (uint i = 0; i < marksAccel.length(); i++) {
if (!marksDict[ marksAccel.mid(i, 1)]) {
marksDict.insert(marksAccel.mid(i, 1), (const int *) 1);
marksAccel = marksAccel.insert(i, '&');
break;
}
}
} else {
marksDict.insert(marksAccel.left(1), (const int *) 1);
marksAccel = "&" + marksAccel;
}
QAction *a = new QAction(marksStr, QIconSet(), marksAccel, 0, ag, 0, ag->isExclusive());
connect(a, SIGNAL(activated()), marksMapper, SLOT(map()));
marksMapper->setMapping(a, a->text());
}
ag->addTo(marks);
marks->setPalette(palette());
marks->popup(QCursor::pos());
}
示例3: setupTextActions
void TextEdit::setupTextActions()
{
QToolBar *tb = new QToolBar( this );
tb->setLabel( "Format Actions" );
QPopupMenu *menu = new QPopupMenu( this );
menuBar()->insertItem( tr( "F&ormat" ), menu );
comboFont = new QComboBox( TRUE, tb );
QFontDatabase db;
comboFont->insertStringList( db.families() );
connect( comboFont, SIGNAL( activated( const QString & ) ),
this, SLOT( textFamily( const QString & ) ) );
comboFont->lineEdit()->setText( QApplication::font().family() );
comboSize = new QComboBox( TRUE, tb );
QValueList<int> sizes = db.standardSizes();
QValueList<int>::Iterator it = sizes.begin();
for ( ; it != sizes.end(); ++it )
comboSize->insertItem( QString::number( *it ) );
connect( comboSize, SIGNAL( activated( const QString & ) ),
this, SLOT( textSize( const QString & ) ) );
comboSize->lineEdit()->setText( QString::number( QApplication::font().pointSize() ) );
actionTextBold = new QAction( QPixmap::fromMimeSource( "textbold.xpm" ), tr( "&Bold" ), CTRL + Key_B, this, "textBold" );
connect( actionTextBold, SIGNAL( activated() ), this, SLOT( textBold() ) );
actionTextBold->addTo( tb );
actionTextBold->addTo( menu );
actionTextBold->setToggleAction( TRUE );
actionTextItalic = new QAction( QPixmap::fromMimeSource( "textitalic.xpm" ), tr( "&Italic" ), CTRL + Key_I, this, "textItalic" );
connect( actionTextItalic, SIGNAL( activated() ), this, SLOT( textItalic() ) );
actionTextItalic->addTo( tb );
actionTextItalic->addTo( menu );
actionTextItalic->setToggleAction( TRUE );
actionTextUnderline = new QAction( QPixmap::fromMimeSource( "textunder.xpm" ), tr( "&Underline" ), CTRL + Key_U, this, "textUnderline" );
connect( actionTextUnderline, SIGNAL( activated() ), this, SLOT( textUnderline() ) );
actionTextUnderline->addTo( tb );
actionTextUnderline->addTo( menu );
actionTextUnderline->setToggleAction( TRUE );
menu->insertSeparator();
QActionGroup *grp = new QActionGroup( this );
connect( grp, SIGNAL( selected( QAction* ) ), this, SLOT( textAlign( QAction* ) ) );
actionAlignLeft = new QAction( QPixmap::fromMimeSource( "textleft.xpm" ), tr( "&Left" ), CTRL + Key_L, grp, "textLeft" );
actionAlignLeft->setToggleAction( TRUE );
actionAlignCenter = new QAction( QPixmap::fromMimeSource( "textcenter.xpm" ), tr( "C&enter" ), CTRL + Key_E, grp, "textCenter" );
actionAlignCenter->setToggleAction( TRUE );
actionAlignRight = new QAction( QPixmap::fromMimeSource( "textright.xpm" ), tr( "&Right" ), CTRL + Key_R, grp, "textRight" );
actionAlignRight->setToggleAction( TRUE );
actionAlignJustify = new QAction( QPixmap::fromMimeSource( "textjustify.xpm" ), tr( "&Justify" ), CTRL + Key_J, grp, "textjustify" );
actionAlignJustify->setToggleAction( TRUE );
grp->addTo( tb );
grp->addTo( menu );
menu->insertSeparator();
QPixmap pix( 16, 16 );
pix.fill( black );
actionTextColor = new QAction( pix, tr( "&Color..." ), 0, this, "textColor" );
connect( actionTextColor, SIGNAL( activated() ), this, SLOT( textColor() ) );
actionTextColor->addTo( tb );
actionTextColor->addTo( menu );
}
示例4: QMainWindow
Themes::Themes( QWidget *parent, const char *name, WFlags f )
: QMainWindow( parent, name, f )
{
appFont = QApplication::font();
tabwidget = new QTabWidget( this );
tabwidget->addTab( new ButtonsGroups( tabwidget ), "Buttons/Groups" );
QHBox *hbox = new QHBox( tabwidget );
hbox->setMargin( 5 );
(void)new LineEdits( hbox );
(void)new ProgressBar( hbox );
tabwidget->addTab( hbox, "Lineedits/Progressbar" );
tabwidget->addTab( new ListBoxCombo( tabwidget ), "Listboxes/Comboboxes" );
tabwidget->addTab( new CheckLists( tabwidget ), "Listviews" );
tabwidget->addTab( new RangeControls( tabwidget ), "Rangecontrols" );
tabwidget->addTab( new MyRichText( tabwidget ), "Fortune" );
setCentralWidget( tabwidget );
QPopupMenu *style = new QPopupMenu( this );
style->setCheckable( TRUE );
menuBar()->insertItem( "&Style" , style );
style->setCheckable( TRUE );
QActionGroup *ag = new QActionGroup( this, 0 );
ag->setExclusive( TRUE );
QSignalMapper *styleMapper = new QSignalMapper( this );
connect( styleMapper, SIGNAL( mapped( const QString& ) ), this, SLOT( makeStyle( const QString& ) ) );
QStringList list = QStyleFactory::keys();
list.sort();
#ifndef QT_NO_STYLE_WINDOWS
list.insert(list.begin(), "Norwegian Wood");
list.insert(list.begin(), "Metal");
#endif
QDict<int> stylesDict( 17, FALSE );
for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
QString styleStr = *it;
QString styleAccel = styleStr;
if ( stylesDict[styleAccel.left(1)] ) {
for ( uint i = 0; i < styleAccel.length(); i++ ) {
if ( !stylesDict[styleAccel.mid( i, 1 )] ) {
stylesDict.insert(styleAccel.mid( i, 1 ), (const int *)1);
styleAccel = styleAccel.insert( i, '&' );
break;
}
}
} else {
stylesDict.insert(styleAccel.left(1), (const int *)1);
styleAccel = "&"+styleAccel;
}
QAction *a = new QAction( styleStr, QIconSet(), styleAccel, 0, ag, 0, ag->isExclusive() );
connect( a, SIGNAL( activated() ), styleMapper, SLOT(map()) );
styleMapper->setMapping( a, a->text() );
}
ag->addTo(style);
style->insertSeparator();
style->insertItem("&Quit", qApp, SLOT( quit() ), CTRL | Key_Q );
QPopupMenu * help = new QPopupMenu( this );
menuBar()->insertSeparator();
menuBar()->insertItem( "&Help", help );
help->insertItem( "&About", this, SLOT(about()), Key_F1);
help->insertItem( "About &Qt", this, SLOT(aboutQt()));
#ifndef QT_NO_STYLE_WINDOWS
qApp->setStyle( new NorwegianWoodStyle );
#endif
}