本文整理汇总了C++中QActionGroup::isExclusive方法的典型用法代码示例。如果您正苦于以下问题:C++ QActionGroup::isExclusive方法的具体用法?C++ QActionGroup::isExclusive怎么用?C++ QActionGroup::isExclusive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QActionGroup
的用法示例。
在下文中一共展示了QActionGroup::isExclusive方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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
}