本文整理汇总了C++中QToolBar::setLabel方法的典型用法代码示例。如果您正苦于以下问题:C++ QToolBar::setLabel方法的具体用法?C++ QToolBar::setLabel怎么用?C++ QToolBar::setLabel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QToolBar
的用法示例。
在下文中一共展示了QToolBar::setLabel方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setupEditActions
void TextEdit::setupEditActions()
{
QToolBar *tb = new QToolBar( this );
tb->setLabel( "Edit Actions" );
QPopupMenu *menu = new QPopupMenu( this );
menuBar()->insertItem( tr( "&Edit" ), menu );
QAction *a;
a = new QAction( QPixmap::fromMimeSource( "editundo.xpm" ), tr( "&Undo" ), CTRL + Key_Z, this, "editUndo" );
connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) );
a->addTo( tb );
a->addTo( menu );
a = new QAction( QPixmap::fromMimeSource( "editredo.xpm" ), tr( "&Redo" ), CTRL + Key_Y, this, "editRedo" );
connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) );
a->addTo( tb );
a->addTo( menu );
menu->insertSeparator();
a = new QAction( QPixmap::fromMimeSource( "editcopy.xpm" ), tr( "&Copy" ), CTRL + Key_C, this, "editCopy" );
connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
a->addTo( tb );
a->addTo( menu );
a = new QAction( QPixmap::fromMimeSource( "editcut.xpm" ), tr( "Cu&t" ), CTRL + Key_X, this, "editCut" );
connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
a->addTo( tb );
a->addTo( menu );
a = new QAction( QPixmap::fromMimeSource( "editpaste.xpm" ), tr( "&Paste" ), CTRL + Key_V, this, "editPaste" );
connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
a->addTo( tb );
a->addTo( menu );
}
示例2: _createToolBar
QToolBar* CGLWin::_createToolBar(void)
{
_fileNewAction = new QAction( QPixmap(filenew_xpm), "&Clear Window", CTRL+Key_N, this);
connect(_fileNewAction, SIGNAL(activated()), this, SLOT(newDoc()));
_fileOpenAction = new QAction( QPixmap(fileopen), "&Open...", CTRL+Key_O, this);
connect(_fileOpenAction, SIGNAL(activated()), this, SLOT(openCia3dFile()));
_fileSaveAction = new QAction( QPixmap(filesave), "&Save snapshot", CTRL+Key_S, this);
connect(_fileSaveAction, SIGNAL(activated()), this, SLOT(save()));
_filePrintAction = new QAction( QPixmap(fileprint), "&Print", CTRL+Key_Q, this);
connect(_filePrintAction, SIGNAL(activated()), this, SLOT(print()));
// populate a tool bar with some actions
QToolBar * fileTools = new QToolBar( this, "file operations" );
fileTools->setLabel( "File Operations" );
_fileNewAction->addTo( fileTools );
_fileOpenAction->addTo( fileTools );
_fileSaveAction->addTo( fileTools );
_filePrintAction->addTo( fileTools );
return fileTools;
}
示例3: setupFileActions
void TextEdit::setupFileActions()
{
QToolBar *tb = new QToolBar( this );
tb->setLabel( "File Actions" );
QPopupMenu *menu = new QPopupMenu( this );
menuBar()->insertItem( tr( "&File" ), menu );
QAction *a;
a = new QAction( QPixmap::fromMimeSource( "filenew.xpm" ), tr( "&New..." ), CTRL + Key_N, this, "fileNew" );
connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
a->addTo( tb );
a->addTo( menu );
a = new QAction( QPixmap::fromMimeSource( "fileopen.xpm" ), tr( "&Open..." ), CTRL + Key_O, this, "fileOpen" );
connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) );
a->addTo( tb );
a->addTo( menu );
menu->insertSeparator();
a = new QAction( QPixmap::fromMimeSource( "filesave.xpm" ), tr( "&Save..." ), CTRL + Key_S, this, "fileSave" );
connect( a, SIGNAL( activated() ), this, SLOT( fileSave() ) );
a->addTo( tb );
a->addTo( menu );
a = new QAction( tr( "Save &As..." ), 0, this, "fileSaveAs" );
connect( a, SIGNAL( activated() ), this, SLOT( fileSaveAs() ) );
a->addTo( menu );
menu->insertSeparator();
a = new QAction( QPixmap::fromMimeSource( "fileprint.xpm" ), tr( "&Print..." ), CTRL + Key_P, this, "filePrint" );
connect( a, SIGNAL( activated() ), this, SLOT( filePrint() ) );
a->addTo( tb );
a->addTo( menu );
a = new QAction( tr( "&Close" ), 0, this, "fileClose" );
connect( a, SIGNAL( activated() ), this, SLOT( fileClose() ) );
a->addTo( menu );
a = new QAction( tr( "E&xit" ), 0, this, "fileExit" );
connect( a, SIGNAL( activated() ), this, SLOT( fileExit() ) );
a->addTo( menu );
}
示例4: 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 );
}
示例5: QMainWindow
kernelinfo::kernelinfo()
: QMainWindow( 0, "kernelinfo", WDestructiveClose )
{
printer = new QPrinter;
QPixmap openIcon, saveIcon, printIcon;
QToolBar * fileTools = new QToolBar( this, "file operations" );
fileTools->setLabel( tr("File Operations") );
openIcon = QPixmap( fileopen );
QToolButton * fileOpen
= new QToolButton( openIcon, tr("Open File"), QString::null,
this, SLOT(choose()), fileTools, "open file" );
saveIcon = QPixmap( filesave );
QToolButton * fileSave
= new QToolButton( saveIcon, tr("Save File"), QString::null,
this, SLOT(save()), fileTools, "save file" );
printIcon = QPixmap( fileprint );
QToolButton * filePrint
= new QToolButton( printIcon, tr("Print File"), QString::null,
this, SLOT(print()), fileTools, "print file" );
(void)QWhatsThis::whatsThisButton( fileTools );
QString fileOpenText = tr("<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>");
QWhatsThis::add( fileOpen, fileOpenText );
QMimeSourceFactory::defaultFactory()->setPixmap( "fileopen", openIcon );
QString fileSaveText = tr("<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>");
QWhatsThis::add( fileSave, fileSaveText );
QString filePrintText = tr("Click this button to print the file you "
"are editing.\n You can also select the Print "
"command from the File menu.");
QWhatsThis::add( filePrint, filePrintText );
QPopupMenu * file = new QPopupMenu( this );
menuBar()->insertItem( tr("&File"), file );
file->insertItem( tr("&New"), this, SLOT(newDoc()), CTRL+Key_N );
int id;
id = file->insertItem( openIcon, tr("&Open..."),
this, SLOT(choose()), CTRL+Key_O );
file->setWhatsThis( id, fileOpenText );
id = file->insertItem( saveIcon, tr("&Save"),
this, SLOT(save()), CTRL+Key_S );
file->setWhatsThis( id, fileSaveText );
id = file->insertItem( tr("Save &As..."), this, SLOT(saveAs()) );
file->setWhatsThis( id, fileSaveText );
file->insertSeparator();
id = file->insertItem( printIcon, tr("&Print..."),
this, SLOT(print()), CTRL+Key_P );
file->setWhatsThis( id, filePrintText );
file->insertSeparator();
file->insertItem( tr("&Close"), this, SLOT(close()), CTRL+Key_W );
file->insertItem( tr("&Quit"), qApp, SLOT( closeAllWindows() ), CTRL+Key_Q );
menuBar()->insertSeparator();
QPopupMenu * help = new QPopupMenu( this );
menuBar()->insertItem( tr("&Help"), help );
help->insertItem( tr("&About"), this, SLOT(about()), Key_F1 );
help->insertItem( tr("About &Qt"), this, SLOT(aboutQt()) );
help->insertSeparator();
help->insertItem( tr("What's &This"), this, SLOT(whatsThis()), SHIFT+Key_F1 );
e = new QTextEdit( this, "editor" );
e->setFocus();
setCentralWidget( e );
statusBar()->message( tr("Ready"), 2000 );
resize( 450, 600 );
}
示例6: QMainWindow
ToolbarDemo::ToolbarDemo()
: QMainWindow(0, "Toolbar Demo")
{
//主窗口本身是一个高级容器
//建立动作
QAction *fileNewAction, *fileOpenAction, *fileSaveAction,
*fileSaveAsAction, *filePrintAction, *fileCloseAction,
*fileQuitAction;
fileNewAction = new QAction( "New", tr("新建(&N)"),
CTRL+Key_N, this, "new" );
connect( fileNewAction, SIGNAL( activated() ) ,this, SLOT( newDoc()));
fileOpenAction = new QAction( "Open File", QPixmap( fileopen ),
tr("打开(&O)"), CTRL+Key_O, this, "open" );
connect( fileOpenAction, SIGNAL( activated() ) , this, SLOT( load() ) );
QMimeSourceFactory::defaultFactory()->setPixmap( "fileopen",
QPixmap( fileopen ) );
fileOpenAction->setWhatsThis( tr(fileOpenText) );
fileSaveAction = new QAction( "Save File", QPixmap( filesave ),
tr("保存(&S)"), CTRL+Key_S, this, "save" );
connect( fileSaveAction, SIGNAL( activated() ) , this, SLOT( save() ) );
fileSaveAction->setWhatsThis( tr(fileSaveText) );
fileSaveAsAction = new QAction( "Save File As", tr("保存为(&s)..."),
0, this, "save as" );
connect( fileSaveAsAction, SIGNAL(activated()),this,SLOT( saveAs() ));
fileSaveAsAction->setWhatsThis( tr(fileSaveText) );
filePrintAction = new QAction( "Print File", QPixmap( fileprint ),
tr("打印(&P)"), CTRL+Key_P, this, "print" );
connect( filePrintAction, SIGNAL(activated()) , this, SLOT(print()));
filePrintAction->setWhatsThis( tr(filePrintText) );
fileCloseAction = new QAction( "Close", tr("关闭(&C)"), CTRL+Key_W,
this, "close" );
connect( fileCloseAction, SIGNAL(activated()) , this, SLOT(close()) );
fileQuitAction = new QAction( "Quit", tr("退出(&Q)"), CTRL+Key_Q,
this, "quit" );
connect(fileQuitAction,SIGNAL(activated()),qApp,SLOT(closeAllWindows()));
//建立按钮条
QToolBar* fileTools = new QToolBar( this, "file operations" );
fileTools->setLabel( "File Operations" );
fileOpenAction->addTo( fileTools );
fileSaveAction->addTo( fileTools );
filePrintAction->addTo( fileTools );
(void)QWhatsThis::whatsThisButton( fileTools );
//建立文件菜单
QPopupMenu * file = new QPopupMenu( this );
menuBar()->insertItem( tr("文件(&F)"), file );
fileNewAction->addTo( file );
fileOpenAction->addTo( file );
fileSaveAction->addTo( file );
fileSaveAsAction->addTo( file );
file->insertSeparator();
filePrintAction->addTo( file );
file->insertSeparator();
fileCloseAction->addTo( file );
fileQuitAction->addTo( file );
//建立帮助菜单
QPopupMenu * help = new QPopupMenu( this );
menuBar()->insertSeparator();
menuBar()->insertItem( tr("帮助(&H)"), help );
help->insertItem( tr("关于(&A)"), this, SLOT(about()), Key_F1 );
help->insertItem( tr("关于 &Qt"), this, SLOT(aboutQt()) );
help->insertSeparator();
help->insertItem(tr("这是什么?"),this,SLOT(whatsThis()),SHIFT+Key_F1);
QMultiLineEdit *e = new QMultiLineEdit( this, "editor" );
e->setFocus();
setCentralWidget( e );
statusBar()->message( tr("准备就绪"), 2000 );
resize( 400, 400 );
}
示例7: QTabWidget
//.........这里部分代码省略.........
// traits menu
/*QPopupMenu * traits = new QPopupMenu( this );
menuBar()->insertItem( "&Traits Type", traits );
setSegmentTraits->addTo(traits);
setPolylineTraits->addTo(traits);
#ifdef CGAL_USE_CORE
setConicTraits->addTo(traits);
#endif
*/
// options menu
QPopupMenu * options = new QPopupMenu( this );
menuBar()->insertItem( "&Options", options );
options->insertSeparator();
//options->insertItem("Overlay...", this, SLOT(overlay_pm()));
options->insertSeparator();
options->insertItem("Properties...", this, SLOT(properties()));
options->insertSeparator();
options->insertItem("Show Grid", this, SLOT(showGrid()));
options->insertItem("Hide Grid", this, SLOT(hideGrid()));
options->insertSeparator();
//options->insertItem("Conic Type", this, SLOT(conicType()));
//options->insertSeparator();
options->insertItem("Unbounded Face Color...", this, SLOT(backGroundColor()));
options->insertSeparator();
options->insertItem("Edge Color...", this, SLOT(changeEdgeColor()));
options->insertSeparator();
options->insertItem("Vertex Color...", this, SLOT(changeVertexColor()));
options->insertSeparator();
/*options->insertItem("Point-Locaiton Strategy....", this ,
SLOT(pointLocationStrategy()));
*/
QToolBar *modeTools = new QToolBar( this, "mode operations" );
modeTools->setLabel( "Mode Operations" );
insertMode->addTo( modeTools );
deleteMode->addTo( modeTools );
pointLocationMode->addTo( modeTools );
dragMode->addTo( modeTools );
modeTools->addSeparator();
QToolBar *snapModeTools = new QToolBar( this, "snapMode operations" );
snapModeTools->setLabel( "Snap Mode Operations" );
snapModeTools->addSeparator();
setSnapMode->addTo( snapModeTools );
setGridSnapMode->addTo( snapModeTools );
snapModeTools->addSeparator();
/*QToolBar *traitsTool = new QToolBar( this, "traits type" );
traitsTool->setLabel( "Traits Type" );
traitsTool->addSeparator();
setSegmentTraits->addTo( traitsTool );
setPolylineTraits->addTo( traitsTool );
#ifdef CGAL_USE_CORE
setConicTraits->addTo( traitsTool );
#endif
traitsTool->addSeparator();
*/
QToolBar *zoomTool = new QToolBar( this, "zoom" );
zoomTool->setLabel( "Zoom" );
zoomTool->addSeparator();
zoomoutBt->addTo( zoomTool );
zoominBt->addTo( zoomTool );
zoomTool->addSeparator();
QToolBar *colorTool = new QToolBar( this, "color" );
colorTool->addSeparator();
示例8: QMainWindow
ThemeDemo::ThemeDemo()
: QMainWindow(0, "Toolbar Demo")
{
appFont = QApplication::font();
//建立动作
QAction *fileNewAction, *fileOpenAction, *fileSaveAction,
*fileSaveAsAction, *filePrintAction, *fileCloseAction,
*fileQuitAction;
fileNewAction = new QAction( "New", tr("新建(&N)"),
CTRL+Key_N, this, "new" );
connect( fileNewAction, SIGNAL( activated() ) ,this, SLOT( newDoc()));
fileOpenAction = new QAction( "Open File", QPixmap( fileopen ),
tr("打开(&O)"), CTRL+Key_O, this, "open" );
connect( fileOpenAction, SIGNAL( activated() ) , this, SLOT( load() ) );
QMimeSourceFactory::defaultFactory()->setPixmap( "fileopen",
QPixmap( fileopen ) );
fileOpenAction->setWhatsThis( tr(fileOpenText) );
fileSaveAction = new QAction( "Save File", QPixmap( filesave ),
tr("保存(&S)"), CTRL+Key_S, this, "save" );
connect( fileSaveAction, SIGNAL( activated() ) , this, SLOT( save() ) );
fileSaveAction->setWhatsThis( tr(fileSaveText) );
fileSaveAsAction = new QAction( "Save File As", tr("保存为(&s)..."),
0, this, "save as" );
connect( fileSaveAsAction, SIGNAL(activated()),this,SLOT( saveAs() ));
fileSaveAsAction->setWhatsThis( tr(fileSaveText) );
filePrintAction = new QAction( "Print File", QPixmap( fileprint ),
tr("打印(&P)"), CTRL+Key_P, this, "print" );
connect( filePrintAction, SIGNAL(activated()) , this, SLOT(print()));
filePrintAction->setWhatsThis( tr(filePrintText) );
fileCloseAction = new QAction( "Close", tr("关闭(&C)"), CTRL+Key_W,
this, "close" );
connect( fileCloseAction, SIGNAL(activated()) , this, SLOT(close()) );
fileQuitAction = new QAction( "Quit", tr("退出(&Q)"), CTRL+Key_Q,
this, "quit" );
connect(fileQuitAction,SIGNAL(activated()),qApp,SLOT(closeAllWindows()));
//建立按钮条
QToolBar* fileTools = new QToolBar( this, "file operations" );
fileTools->setLabel( "File Operations" );
fileOpenAction->addTo( fileTools );
fileSaveAction->addTo( fileTools );
filePrintAction->addTo( fileTools );
(void)QWhatsThis::whatsThisButton( fileTools );
//建立文件菜单
QPopupMenu * file = new QPopupMenu( this );
menuBar()->insertItem( tr("文件(&F)"), file );
fileNewAction->addTo( file );
fileOpenAction->addTo( file );
fileSaveAction->addTo( file );
fileSaveAsAction->addTo( file );
file->insertSeparator();
filePrintAction->addTo( file );
file->insertSeparator();
fileCloseAction->addTo( file );
fileQuitAction->addTo( file );
//建立Style菜单
QPopupMenu *style = new QPopupMenu( this );
style->setCheckable( TRUE );
menuBar()->insertItem( tr("风格(&S)") , style );
sMetal = style->insertItem( "&Metal", this, SLOT( styleMetal() ) );
sWood = style->insertItem( "&Norwegian Wood", this, SLOT( styleWood() ) );
sPlatinum = style->insertItem( "&Platinum" , this ,SLOT( stylePlatinum() ) );
sWindows = style->insertItem( "&Windows", this, SLOT( styleWindows() ) );
sCDE = style->insertItem( "&CDE", this, SLOT( styleCDE() ) );
sMotif = style->insertItem( "M&otif", this, SLOT( styleMotif() ) );
sMotifPlus = style->insertItem( "Motif P&lus", this, SLOT( styleMotifPlus() ) );
//建立帮助菜单
QPopupMenu * help = new QPopupMenu( this );
menuBar()->insertSeparator();
menuBar()->insertItem( tr("帮助(&H)"), help );
help->insertItem( tr("关于(&A)"), this, SLOT(about()), Key_F1 );
help->insertItem( tr("关于 &Qt"), this, SLOT(aboutQt()) );
help->insertSeparator();
help->insertItem(tr("这是什么?"),this,SLOT(whatsThis()),SHIFT+Key_F1);
QMultiLineEdit *e = new QMultiLineEdit( this, "editor" );
e->setFocus();
setCentralWidget( e );
statusBar()->message( tr("准备就绪"), 2000 );
resize( 400, 400 );
}
示例9: 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
//.........这里部分代码省略.........
示例10: setIcon
Main::Main()
{
setIcon( (const char**)logo_xpm );
#ifdef FIXED_LAYOUT
QHBox* horizontal = new QHBox(this);
#else
QSplitter* horizontal = new QSplitter(this);
#endif
lv = new QListView(horizontal);
lv->setSorting(-1);
lv->setRootIsDecorated(TRUE);
lv->addColumn("ID");
info = new Info(horizontal);
info->setBackgroundMode(PaletteBase);
info->setMargin(10);
info->setFrameStyle(QFrame::WinPanel|QFrame::Sunken);
info->setAlignment(AlignTop);
connect(info, SIGNAL(idClicked(const QString&)),
this, SLOT(selectId(const QString&)));
#ifdef FIXED_LAYOUT
horizontal->setStretchFactor(info,2);
#endif
connect(lv, SIGNAL(pressed(QListViewItem*)),
this, SLOT(updateAvailability(QListViewItem*)));
connect(lv, SIGNAL(selectionChanged(QListViewItem*)),
this, SLOT(showInfo(QListViewItem*)));
setCentralWidget(horizontal);
QToolBar* tb = new QToolBar( this, "browser controls" );
tb->setLabel( "Browser Controls" );
(void)new QToolButton( QPixmap(back_xpm), "Back", QString::null,
info, SLOT(back()), tb, "back" );
(void)new QToolButton( QPixmap(forward_xpm), "Forward", QString::null,
info, SLOT(forward()), tb, "forward" );
QPopupMenu* file = new QPopupMenu( menuBar() );
file->insertItem( "&Open", this, SLOT(open()), CTRL+Key_O );
file->insertItem( "&Save", this, SLOT(save()), CTRL+Key_S );
file->insertSeparator();
file->insertItem( "&Test all", this, SLOT(testAll()), CTRL+Key_T );
file->insertSeparator();
file->insertItem( "E&xit", qApp, SLOT(quit()), CTRL+Key_Q );
menuBar()->insertItem( "&File",file );
menuBar()->insertSeparator();
QPopupMenu *help = new QPopupMenu( menuBar() );
help->insertItem( "&About", this, SLOT(about()) );
help->insertItem( "About &Qt", this, SLOT(aboutQt()) );
menuBar()->insertItem( "&Help", help );
statusBar()->message( "Ready" );
}