本文整理汇总了C++中QPopupMenu::insertItem方法的典型用法代码示例。如果您正苦于以下问题:C++ QPopupMenu::insertItem方法的具体用法?C++ QPopupMenu::insertItem怎么用?C++ QPopupMenu::insertItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPopupMenu
的用法示例。
在下文中一共展示了QPopupMenu::insertItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: slotSave
/*
Scribble::Scribble( QWidget *parent, const char *name )
: QMainWindow( parent, name )
{
canvas = new Canvas( this );
setCentralWidget( canvas );
QToolBar *tools = new QToolBar( this );
bSave = new QPushButton( "Save as...", tools );
tools->addSeparator();
bPColor = new QPushButton( "Choose Pen Color...", tools );
// bPColor->setText( "Choose Pen Color..." );
tools->addSeparator();
bPWidth = new QSpinBox( 1, 20, 1, tools );
QToolTip::add( bPWidth, "Choose Pen Width" );
connect( bPWidth, SIGNAL( valueChanged( int ) ), this, SLOT( slotWidth( int ) ) );
bPWidth->setValue( 3 );
tools->addSeparator();
bClear = new QPushButton( "Clear Screen", tools );
QObject::connect( bSave, SIGNAL( clicked() ), this, SLOT( slotSave() ) );
QObject::connect( bPColor, SIGNAL( clicked() ), this, SLOT( slotColor() ) );
QObject::connect( bClear, SIGNAL( clicked() ), this, SLOT( slotClear() ) );
}
*/
void Scribble::slotSave()
{
QPopupMenu *menu = new QPopupMenu( 0 );
QIntDict<QString> formats;
formats.setAutoDelete( TRUE );
for ( unsigned int i = 0; i < QImageIO::outputFormats().count(); i++ ) {
QString str = QString( QImageIO::outputFormats().at( i ) );
formats.insert( menu->insertItem( QString( "%1..." ).arg( str ) ), new QString( str ) );
}
menu->setMouseTracking( TRUE );
int id = menu->exec( bSave->mapToGlobal( QPoint( 0, bSave->height() + 1 ) ) );
if ( id != -1 ) {
QString format = *formats[ id ];
QString filename = QFileDialog::getSaveFileName( QString::null, QString( "*.%1" ).arg( format.lower() ), this );
if ( !filename.isEmpty() )
canvas->save( filename, format );
}
delete menu;
}
示例2: showAttendeeStatusMenu
void KOEditorFreeBusy::showAttendeeStatusMenu()
{
if ( mGanttView->mapFromGlobal( QCursor::pos() ).x() > 22 )
return;
QPopupMenu popup;
popup.insertItem( SmallIcon( "help" ), Attendee::statusName( Attendee::NeedsAction ), Attendee::NeedsAction );
popup.insertItem( KOGlobals::self()->smallIcon( "ok" ), Attendee::statusName( Attendee::Accepted ), Attendee::Accepted );
popup.insertItem( KOGlobals::self()->smallIcon( "no" ), Attendee::statusName( Attendee::Declined ), Attendee::Declined );
popup.insertItem( KOGlobals::self()->smallIcon( "apply" ), Attendee::statusName( Attendee::Tentative ), Attendee::Tentative );
popup.insertItem( KOGlobals::self()->smallIcon( "mail_forward" ), Attendee::statusName( Attendee::Delegated ), Attendee::Delegated );
popup.insertItem( Attendee::statusName( Attendee::Completed ), Attendee::Completed );
popup.insertItem( KOGlobals::self()->smallIcon( "help" ), Attendee::statusName( Attendee::InProcess ), Attendee::InProcess );
popup.setItemChecked( currentAttendee()->status(), true );
int status = popup.exec( QCursor::pos() );
if ( status >= 0 ) {
currentAttendee()->setStatus( (Attendee::PartStat)status );
updateCurrentItem();
updateAttendeeInput();
}
}
示例3: initMenuBar
void InterfaceDuel::initMenuBar()
{
QPopupMenu * menuFile = new QPopupMenu();
CHECK_PTR( menuFile );
menuFile->insertItem( "Load Game", FIL_LOAD );
menuFile->insertItem( "Save Game", FIL_SAVE );
menuFile->insertItem( "Start Game", FIL_START );
menuFile->insertItem( "End Game", FIL_END );
menuFile->insertItem( "Quit", FIL_QUIT );
connect( menuFile, SIGNAL( activated( int ) ), this, SLOT( slot_menuFileActivated( int ) ) );
QPopupMenu * menuGame = new QPopupMenu();
CHECK_PTR( menuGame );
menuGame->insertItem( "Fight", GAM_FIG );
menuGame->insertItem( "End Fight", GAM_END );
connect( menuGame, SIGNAL( activated( int ) ), this, SLOT( slot_menuGameActivated( int ) ) );
menuBar()->insertItem( "&File", menuFile );
menuBar()->insertItem( "&Game", menuGame );
}
示例4: initMenuBar
void VirtualConsole::initMenuBar()
{
QString dir;
_app->settings()->get(KEY_SYSTEM_DIR, dir);
dir += QString("/") + PIXMAPPATH;
setIcon(dir + QString("/virtualconsole.xpm"));
m_layout = new QHBoxLayout(this);
m_layout->setAutoAdd(false);
m_menuBar = new QMenuBar(this);
m_layout->setMenuBar(m_menuBar);
//
// Add menu
//
m_addMenu = new QPopupMenu();
m_addMenu->insertItem(QPixmap(dir + "/button.xpm"),
"&Button", this, SLOT(slotAddButton()),
0, KVCMenuAddButton);
m_addMenu->insertItem(QPixmap(dir + "/slider.xpm"),
"&Slider", this, SLOT(slotAddSlider()),
0, KVCMenuAddSlider);
m_addMenu->insertItem(QPixmap(dir + "/frame.xpm"),
"&Frame", this, SLOT(slotAddFrame()),
0, KVCMenuAddFrame);
m_addMenu->insertItem(QPixmap(dir + "/frame.xpm"),
"&XY-Pad", this, SLOT(slotAddXYPad()),
0, KVCMenuAddXYPad);
m_addMenu->setItemEnabled(KVCMenuAddXYPad, false);
m_addMenu->insertItem(QPixmap(dir + "/rename.xpm"),
"L&abel", this, SLOT(slotAddLabel()),
0, KVCMenuAddLabel);
//
// Tools menu
//
m_toolsMenu = new QPopupMenu();
m_toolsMenu->insertItem(QPixmap(dir + "/settings.xpm"),
"&Settings...", this, SLOT(slotToolsSettings()),
0, KVCMenuToolsSettings);
m_toolsMenu->insertItem(QPixmap(dir + "/slider.xpm"),
"&Default Sliders", this, SLOT(slotToolsSliders()),
0, KVCMenuToolsSliders);
m_toolsMenu->insertSeparator();
m_toolsMenu->insertItem(QPixmap(dir + "/panic.xpm"),
"&Panic!", this, SLOT(slotToolsPanic()),
0, KVCMenuToolsPanic);
//
// Foreground menu
//
QPopupMenu* fgMenu = new QPopupMenu();
fgMenu->insertItem(QPixmap(dir + QString("/color.xpm")),
"&Color...", this, SLOT(slotForegroundColor()),
0, KVCMenuForegroundColor);
fgMenu->insertItem(QPixmap(dir + QString("/rename.xpm")),
"&Font...", this, SLOT(slotForegroundFont()),
0, KVCMenuForegroundFont);
fgMenu->insertItem(QPixmap(dir + QString("/fileclose.xpm")),
"&Default", this, SLOT(slotForegroundNone()),
0, KVCMenuForegroundNone);
//
// Background Menu
//
QPopupMenu* bgMenu = new QPopupMenu();
bgMenu->insertItem(QPixmap(dir + QString("/color.xpm")),
"&Color...", this, SLOT(slotBackgroundColor()),
0, KVCMenuBackgroundColor);
bgMenu->insertItem(QPixmap(dir + QString("/image.xpm")),
"&Image...", this, SLOT(slotBackgroundImage()),
0, KVCMenuBackgroundPixmap);
bgMenu->insertItem(QPixmap(dir + QString("/fileclose.xpm")),
"&Default", this, SLOT(slotBackgroundNone()),
0, KVCMenuBackgroundNone);
bgMenu->insertSeparator();
bgMenu->insertItem(QPixmap(dir + QString("/frame.xpm")),
"Toggle &Frame", this, SLOT(slotBackgroundFrame()),
0, KVCMenuBackgroundFrame);
//
// Stacking order menu
//
QPopupMenu* stackMenu = new QPopupMenu();
stackMenu->insertItem(QPixmap(dir + QString("/up.xpm")),
"&Raise", this, SLOT(slotStackingRaise()),
0, KVCMenuStackingRaise);
stackMenu->insertItem(QPixmap(dir + QString("/down.xpm")),
"&Lower", this, SLOT(slotStackingLower()),
0, KVCMenuStackingLower);
//
// Edit menu
//
m_editMenu = new QPopupMenu();
m_editMenu->insertItem(QPixmap(dir + "/editcut.xpm"),
"Cut", this, SLOT(slotEditCut()),
//.........这里部分代码省略.........
示例5: SLOT
void
ItemXML::contextMenu(QPopupMenu& _menu)
{
_menu.insertItem("Set Name", this, SLOT(slotRename()));
_menu.insertSeparator();
}
示例6: SLOT
void
NotifySubscribe::contextMenu(QPopupMenu& _menu)
{
_menu.insertItem("subscription change", this, SLOT(subscriptionChange()));
}
示例7: QWidget
/*
In the constructor, we just pass the standard parameters on to
QWidget.
The menu uses a single slot to simplify the process of adding
more items to the options menu.
*/
ImageViewer::ImageViewer( QWidget *parent, const char *name, int wFlags )
: QWidget( parent, name, wFlags ),
conversion_flags( PreferDither ),
helpmsg( 0 )
{
pickx = -1;
picky = -1;
clickx = -1;
clicky = -1;
alloc_context = 0;
menubar = new QMenuBar(this);
menubar->setSeparator( QMenuBar::InWindowsStyle );
QStrList fmt = QImage::outputFormats();
saveimage = new QPopupMenu( menubar );
savepixmap = new QPopupMenu( menubar );
for (const char* f = fmt.first(); f; f = fmt.next()) {
saveimage->insertItem( f );
savepixmap->insertItem( f );
}
connect( saveimage, SIGNAL(activated(int)), this, SLOT(saveImage(int)) );
connect( savepixmap, SIGNAL(activated(int)), this, SLOT(savePixmap(int)) );
file = new QPopupMenu( menubar );
menubar->insertItem( "&File", file );
file->insertItem( "&New window", this, SLOT(newWindow()), CTRL+Key_N );
file->insertItem( "&Open...", this, SLOT(openFile()), CTRL+Key_O );
si = file->insertItem( "Save image", saveimage );
sp = file->insertItem( "Save pixmap", savepixmap );
file->insertSeparator();
file->insertItem( "E&xit", qApp, SLOT(quit()), CTRL+Key_Q );
edit = new QPopupMenu( menubar );
menubar->insertItem( "&Edit", edit );
edit->insertItem("&Copy", this, SLOT(copy()), CTRL+Key_C);
edit->insertItem("&Paste", this, SLOT(paste()), CTRL+Key_V);
edit->insertSeparator();
edit->insertItem("&Horizontal flip", this, SLOT(hFlip()), ALT+Key_H);
edit->insertItem("&Vertical flip", this, SLOT(vFlip()), ALT+Key_V);
edit->insertItem("&Rotate 180", this, SLOT(rot180()), ALT+Key_R);
edit->insertSeparator();
edit->insertItem("&Text...", this, SLOT(editText()));
edit->insertSeparator();
t1 = edit->insertItem( "Convert to &1 bit", this, SLOT(to1Bit()) );
t8 = edit->insertItem( "Convert to &8 bit", this, SLOT(to8Bit()) );
t32 = edit->insertItem( "Convert to &32 bit", this, SLOT(to32Bit()) );
options = new QPopupMenu( menubar );
menubar->insertItem( "&Options", options );
ac = options->insertItem( "AutoColor" );
co = options->insertItem( "ColorOnly" );
mo = options->insertItem( "MonoOnly" );
options->insertSeparator();
fd = options->insertItem( "DiffuseDither" );
bd = options->insertItem( "OrderedDither" );
td = options->insertItem( "ThresholdDither" );
options->insertSeparator();
ta = options->insertItem( "ThresholdAlphaDither" );
ba = options->insertItem( "OrderedAlphaDither" );
fa = options->insertItem( "DiffuseAlphaDither" );
options->insertSeparator();
ad = options->insertItem( "PreferDither" );
dd = options->insertItem( "AvoidDither" );
options->insertSeparator();
ss = options->insertItem( "Smooth scaling" );
cc = options->insertItem( "Use color context" );
if ( QApplication::colorSpec() == QApplication::ManyColor )
options->setItemEnabled( cc, FALSE );
options->setCheckable( TRUE );
setMenuItemFlags();
menubar->insertSeparator();
QPopupMenu* help = new QPopupMenu( menubar );
menubar->insertItem( "&Help", help );
help->insertItem( "Help!", this, SLOT(giveHelp()), CTRL+Key_H );
connect( options, SIGNAL(activated(int)), this, SLOT(doOption(int)) );
status = new QLabel(this);
status->setFrameStyle( QFrame::WinPanel | QFrame::Sunken );
status->setFixedHeight( fontMetrics().height() + 4 );
setMouseTracking( TRUE );
}
示例8: QWidget
MyWidget::MyWidget( EventChannel_ptr _ec,
const std::string& _context,
QWidget *parent, const char *name ) :
QWidget( parent, name ),
supplier(_ec, _context),
context( _context )
{
QBoxLayout *topLayout = new QHBoxLayout(this, 5);
// the menu
QPopupMenu *fileMenu = new QPopupMenu( this );
fileMenu->insertItem( "&Load", this, SLOT( load() ) );
fileMenu->insertItem( "&Quit", qApp, SLOT( quit() ) );
menuBar = new QMenuBar( this );
menuBar->insertItem( "&File", fileMenu );
// ... add to layout
topLayout->setMenuBar(menuBar);
// the widgets
playButton = new QPushButton( "Play", this, "play" );
playButton->setMinimumSize(90, 30);
stopButton = new QPushButton( "Stop", this, "stop" );
stopButton->setMinimumSize(90, 30);
pauseButton = new QPushButton( "Pause", this, "pause" );
pauseButton->setMinimumSize(90, 30);
nextButton = new QPushButton( "Next", this, "next" );
nextButton->setMinimumSize(90, 30);
prevButton = new QPushButton( "Prev", this, "prev" );
prevButton->setMinimumSize(90, 30);
secLabel = new QLCDNumber( 3, this, "sec" );
centiSecLabel = new QLCDNumber( 2, this, "sec" );
timeSlider = new QSlider( Horizontal, this, "time" );
timeSlider->setRange(0, 1000);
timeSlider->setValue(0);
speedDial = new QDial( 10, 200, 10, 10, this, "speed" );
speedDial->setWrapping(false);
// ... add to the layout
QBoxLayout *layout1 = new QVBoxLayout(topLayout, 5);
QGridLayout *layout2 = new QGridLayout(layout1, 2, 3, 5);
layout2->addWidget(playButton, 0, 0);
layout2->addWidget(stopButton, 0, 1);
layout2->addWidget(pauseButton, 0, 2);
layout2->addWidget(prevButton, 1, 0);
QBoxLayout *layout3 = new QHBoxLayout(layout2);
layout2->addWidget(nextButton, 1, 2);
layout3->addWidget(secLabel);
layout3->addWidget(centiSecLabel);
layout1->addSpacing(10);
layout1->addWidget(timeSlider);
topLayout->addWidget(speedDial);
// signals n slots
connect( timeSlider, SIGNAL( valueChanged(int) ),
(MyWidget *)this, SLOT( changed(int) ) );
connect( timeSlider, SIGNAL( sliderPressed() ),
(MyWidget *)this, SLOT( beginAction() ) );
connect( timeSlider, SIGNAL( sliderReleased() ),
(MyWidget *)this, SLOT( endAction() ) );
connect( timeSlider, SIGNAL( sliderMoved( int ) ),
(MyWidget *)this, SLOT( timeAction( int ) ) );
connect( &timer, SIGNAL( timeout() ),
(MyWidget *)this, SLOT( step() ) );
connect( playButton, SIGNAL( clicked() ),
(MyWidget *)this, SLOT( play() ) );
connect( stopButton, SIGNAL( clicked() ),
(MyWidget *)this, SLOT( stop() ) );
connect( pauseButton, SIGNAL( clicked() ),
(MyWidget *)this, SLOT( pause() ) );
connect( prevButton, SIGNAL( clicked() ),
(MyWidget *)this, SLOT( prev() ) );
connect( nextButton, SIGNAL( clicked() ),
(MyWidget *)this, SLOT( next() ) );
connect( speedDial, SIGNAL( valueChanged( int ) ),
(MyWidget *)this, SLOT( speed( int ) ) );
connect( speedDial, SIGNAL( dialPressed() ),
(MyWidget *)this, SLOT( beginAction() ) );
connect( speedDial, SIGNAL( dialReleased() ),
(MyWidget *)this, SLOT( endAction() ) );
action = false;
timeSpeed = 10;
}
示例9: setCentralWidget
// constructor
MyWindow::MyWindow(int w, int h) :
red_active(false),
red_set(*(new Polygon_set)),
blue_set(*(new Polygon_set)),
res_set(*(new Polygon_set))
{
widget = new CGAL::Qt_widget(this); //Constructs a widget which is a child of this window
/* Sets the central widget for this main window to w.
* The central widget is surrounded by the left, top, right and bottom dock areas.
* The menu bar is above the top dock area
*/
setCentralWidget(widget);
file_name= QString::null;
//create a timer for checking if somthing changed
QTimer *timer = new QTimer( this ); // constructs a timer whose parent is this window
connect( timer, SIGNAL(timeout()),
this, SLOT(timer_done()) ); // connects the timer to the window
timer->start( 200, FALSE ); // Starts the timer with a msec milliseconds timeout
// file menu
QPopupMenu * file = new QPopupMenu( this );
menuBar()->insertItem( "&File", file );
file->insertItem("&New", this, SLOT(new_instance()), CTRL+Key_N);
file->insertItem("New &Window", this, SLOT(new_window()), CTRL+Key_W);
file->insertSeparator();
file->insertItem("&Open Linear Polygon file", this, SLOT(open_linear_polygon_file()),CTRL+Key_O);
file->insertItem("&Open DXF file", this, SLOT(open_dxf_file()),CTRL+Key_D);
file->insertSeparator();
//file->insertItem("&Save",this ,SLOT(save_file()),CTRL+Key_S);
//file->insertItem("&Save as",this ,SLOT(save_file_as()));
file->insertSeparator();
file->insertItem("Print", widget, SLOT(print_to_ps()), CTRL+Key_P);
file->insertSeparator();
file->insertItem( "&Close", this, SLOT(close()), CTRL+Key_X );
file->insertItem( "&Quit", qApp, SLOT( closeAllWindows() ), CTRL+Key_Q );
// help menu
QPopupMenu * help = new QPopupMenu( this );
menuBar()->insertItem( "&Help", help );
help->insertItem("How To", this, SLOT(howto()), Key_F1);
help->insertSeparator();
help->insertItem("&About", this, SLOT(about()), CTRL+Key_A );
help->insertItem("About &Qt", this, SLOT(aboutQt()) );
//the standard toolbar
stoolbar = new CGAL::Qt_widget_standard_toolbar (widget, this, "ST");
radiotoolbar = new QToolBar(this, "polygon type");
blue_pgn = new QRadioButton ("Blue", radiotoolbar);
blue_pgn->toggle();
red_pgn = new QRadioButton("Red", radiotoolbar);
radio_group = new QVButtonGroup(this,"Radios");
radio_group->insert(blue_pgn);
radio_group->insert(red_pgn);
radio_group->setRadioButtonExclusive(true);
connect(blue_pgn, SIGNAL(toggled (bool)),
this, SLOT(radio_selected()));
connect(red_pgn, SIGNAL(toggled (bool)),
this, SLOT(radio_selected()));
//layers
//widget->attach(&testlayer);
//the new tools toolbar
newtoolbar = new Tools_toolbar(widget, this);
// voronoi toolbar
bops_toolbar = new QToolBar(this, "Boolean operations");
QIconSet set0(QPixmap( (const char**)intersection_xpm ),
QPixmap( (const char**)intersection_xpm ));
intersection_but = new QToolButton(bops_toolbar, "Boolean operations");
intersection_but->setAutoRaise(TRUE);
intersection_but->setIconSet(set0);
intersection_but->setTextLabel("Intersection ");
connect(intersection_but,SIGNAL(pressed()),
this, SLOT(perform_intersection()));
QIconSet set1(QPixmap( (const char**)union_xpm ),
QPixmap( (const char**)union_xpm ));
bops_toolbar->addSeparator();
union_but = new QToolButton(bops_toolbar, "Boolean operations");
union_but->setAutoRaise(TRUE);
union_but->setIconSet(set1);
union_but->setTextLabel("Union ");
connect(union_but,SIGNAL(pressed()),
this, SLOT(perform_union()));
//.........这里部分代码省略.........
示例10: icon_back
FLHelpWindow::FLHelpWindow(const QString &home_,
const QString &_path,
QWidget *parent,
const char *name) :
QMainWindow(parent, name, WDestructiveClose),
pathCombo(0), selectedURL()
{
readHistory();
readBookmarks();
browser = new QTextBrowser(this);
browser->mimeSourceFactory() ->setFilePath(_path);
browser->setFrameStyle(QFrame::Panel | QFrame::Sunken);
connect(browser, SIGNAL(textChanged()), this, SLOT(textChanged()));
setCentralWidget(browser);
if (!home_.isEmpty())
browser->setSource(home_);
connect(browser, SIGNAL(highlighted(const QString &)), statusBar(),
SLOT(message(const QString &)));
resize(640, 700);
QPopupMenu *file = new QPopupMenu(this);
file->insertItem(tr("&Imprimir"), this, SLOT(print()), CTRL + Key_I);
file->insertSeparator();
file->insertItem(tr("&Cerrar"), this, SLOT(close()), Key_Escape);
// The same three icons are used twice each.
QIconSet icon_back(QPixmap::fromMimeSource("previous.png"));
QIconSet icon_forward(QPixmap::fromMimeSource("next.png"));
QIconSet icon_home(QPixmap::fromMimeSource("home.png"));
QPopupMenu *go = new QPopupMenu(this);
backwardId =
go->insertItem(icon_back, tr("&Atrás"), browser, SLOT(backward()),
CTRL + Key_Left);
forwardId =
go->insertItem(icon_forward, tr("&Adelante"), browser,
SLOT(forward()), CTRL + Key_Right);
go->insertItem(icon_home, tr("&Inicio"), browser, SLOT(home()));
QPopupMenu *help = new QPopupMenu(this);
help->insertItem(tr("&Acerca ..."), this, SLOT(about()));
help->insertItem(tr("Acerca de &Qt ..."), this, SLOT(aboutQt()));
hist = new QPopupMenu(this);
QStringList::Iterator it = history.begin();
for (; it != history.end(); ++it)
mHistory[ hist->insertItem(*it)] = *it;
connect(hist, SIGNAL(activated(int)), this, SLOT(histChosen(int)));
bookm = new QPopupMenu(this);
bookm->insertItem(tr("Agregar Favorito"), this, SLOT(addBookmark()));
bookm->insertSeparator();
QStringList::Iterator it2 = bookmarks.begin();
for (; it2 != bookmarks.end(); ++it2)
mBookmarks[ bookm->insertItem(*it2)] = *it2;
connect(bookm, SIGNAL(activated(int)), this, SLOT(bookmChosen(int)));
menuBar() ->insertItem(tr("&Archivo"), file);
menuBar() ->insertItem(tr("&Ir"), go);
menuBar() ->insertItem(tr("Historial"), hist);
menuBar() ->insertItem(tr("Favoritos"), bookm);
menuBar() ->insertSeparator();
menuBar() ->insertItem(tr("&Ayuda"), help);
menuBar() ->setItemEnabled(forwardId, FALSE);
menuBar() ->setItemEnabled(backwardId, FALSE);
connect(browser, SIGNAL(backwardAvailable(bool)), this,
SLOT(setBackwardAvailable(bool)));
connect(browser, SIGNAL(forwardAvailable(bool)), this,
SLOT(setForwardAvailable(bool)));
QToolBar *toolbar = new QToolBar(this);
addToolBar(toolbar, "Toolbar");
QToolButton *button;
button =
new QToolButton(icon_back, tr("Atrás"), "", browser, SLOT(backward()),
toolbar);
connect(browser, SIGNAL(backwardAvailable(bool)), button,
SLOT(setEnabled(bool)));
button->setEnabled(FALSE);
button =
new QToolButton(icon_forward, tr("Adelante"), "", browser,
SLOT(forward()), toolbar);
connect(browser, SIGNAL(forwardAvailable(bool)), button,
SLOT(setEnabled(bool)));
button->setEnabled(FALSE);
button =
//.........这里部分代码省略.........
示例11: 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 );
}
示例12: initMenu
int HexWidget::initMenu() {
windowList.append(this);
CurrentFile=new HexFile(this);
unsaved( false );
connect(CurrentFile, SIGNAL( unsaved(bool) ), SLOT( unsaved(bool) ));
QPopupMenu *file = new QPopupMenu;
file->insertItem( i18n("&New Window..."), ID_FILE_NEWWIN);
file->insertSeparator();
file->insertItem( i18n("&Open..."), ID_FILE_OPEN );
file->insertItem( i18n("&Save"), ID_FILE_SAVE);
file->insertItem( i18n("Save &As..."), ID_FILE_SAVEAS);
file->insertItem( i18n("&Close"), ID_FILE_CLOSE);
file->insertSeparator();
file->insertItem( i18n("&Quit"), ID_FILE_QUIT);
QPopupMenu *edit = new QPopupMenu;
edit->insertItem( i18n("&Copy"), ID_EDIT_COPY);
edit->insertItem( i18n("&Paste"), ID_EDIT_PASTE);
edit->insertItem( i18n("C&ut"), ID_EDIT_CUT);
QPopupMenu *view = new QPopupMenu;
view->insertItem( i18n("&Toggle Toolbar"), ID_VIEW_TOOLBAR);
// view->insertItem( "Toggle Statusbar", ID_VIEW_STATUSBAR);
QPopupMenu *help = kapp->getHelpMenu(true, QString(i18n("Hex Editor"))
+ " " + KHEXDIT_VERSION
+ i18n("\n\nby Stephan Kulow")
+ " ([email protected])");
connect (file, SIGNAL (activated (int)), SLOT (menuCallback (int)));
connect (edit, SIGNAL (activated (int)), SLOT (menuCallback (int)));
connect (help, SIGNAL (activated (int)), SLOT (menuCallback (int)));
connect (view, SIGNAL (activated (int)), SLOT (menuCallback (int)));
menu = new KMenuBar( this );
CHECK_PTR( menu );
menu->insertItem( i18n("&File"), file );
menu->insertItem( i18n("&Edit"), edit);
menu->insertItem( i18n("&View"), view );
menu->insertSeparator();
menu->insertItem( i18n("&Help"), help );
menu->show();
setMenu(menu);
KIconLoader *loader = kapp->getIconLoader();
toolbar = new KToolBar(this);
toolbar->insertButton(loader->loadIcon("filenew.xpm"),
ID_FILE_NEWWIN, true,
i18n("New Window"));
toolbar->insertButton(loader->loadIcon("fileopen.xpm"),ID_FILE_OPEN, true,
i18n("Open a file"));
toolbar->insertButton(loader->loadIcon("filefloppy.xpm"), ID_FILE_SAVE,
true, i18n("Save the file"));
toolbar->insertSeparator();
toolbar->insertButton(loader->loadIcon("editcut.xpm"),ID_EDIT_CUT, false,
i18n("Not implemented"));
toolbar->insertButton(loader->loadIcon("editcopy.xpm"),ID_EDIT_COPY, false,
i18n("Not implemented"));
toolbar->insertButton(loader->loadIcon("editpaste.xpm"),ID_EDIT_PASTE,
false, i18n("Not implemented"));
toolbar->insertSeparator();
toolbar->insertButton(loader->loadIcon("fileprint.xpm"),ID_FILE_PRINT,
false, i18n("Not implemented"));
addToolBar(toolbar);
toolbar->setBarPos(KToolBar::Top);
toolbar->show();
connect(toolbar, SIGNAL(clicked(int)), SLOT(menuCallback(int)));
// KStatusBar *stat = new KStatusBar(this);
// stat->show();
// setStatusBar(stat);
kfm = 0L;
setView(CurrentFile);
dropZone = new KDNDDropZone( this , DndURL);
connect( dropZone, SIGNAL( dropAction( KDNDDropZone *) ),
SLOT( slotDropEvent( KDNDDropZone *) ) );
show();
return 0;
}
示例13: QTabWidget
//.........这里部分代码省略.........
"&Circle", 0 ,conicTypeGroup,
"Circle" );
setCircle->setToggleAction( TRUE );
setSegment = new QAction("Segment",
QPixmap( (const char**)demo_conic_segment_xpm ),
"&Segment", 0 ,conicTypeGroup,
"Segment" );
setSegment->setToggleAction( TRUE );
setEllipse = new QAction("Ellipse",
QPixmap( (const char**)demo_conic_ellipse_xpm ),
"&Ellipse", 0 ,conicTypeGroup,
"Ellipse" );
setEllipse->setToggleAction( TRUE );
setParabola = new QAction("3 Points Arc",
QPixmap( (const char**)demo_conic_3points_xpm ),
"&3 Points Arc", 0 ,conicTypeGroup,
"3 Points Arc" );
setParabola->setToggleAction( TRUE );
setHyperbola = new QAction("5 Points Arc",
QPixmap( (const char**)demo_conic_5points_xpm ),
"&5 Points Arc", 0 ,conicTypeGroup,
"5 Points Arc" );
setHyperbola->setToggleAction( TRUE );
#endif
*/
//create a timer for checking if somthing changed
QTimer *timer = new QTimer( this );
connect( timer, SIGNAL(timeout()),
this, SLOT(timer_done()) );
timer->start( 200, FALSE );
// file menu
QPopupMenu * file = new QPopupMenu( this );
menuBar()->insertItem( "&File", file );
/*
file->insertItem("&Open Segment File...", this, SLOT(fileOpenSegment()));
file->insertItem("&Open Polyline File...", this, SLOT(fileOpenPolyline()));\
file->insertItem("&Open Segment Arr File...", this, SLOT(fileOpenSegmentPm()));
file->insertItem("&Open Polyline Arr File...", this, SLOT(fileOpenPolylinePm()));
file->insertItem("&Open Conic Pm File", this, SLOT(fileOpenConicPm()));
*/
file->insertItem("&Open Input File...", this, SLOT(fileOpenSegment()));
file->insertItem("&Open Output File...", this, SLOT(fileOpenConic()));
file->insertItem("&Save...", this, SLOT(fileSave()));
file->insertItem("&Save As...", this, SLOT(fileSaveAs()));
//file->insertItem("&Save to ps...", this, SLOT(fileSave_ps()));
file->insertSeparator();
file->insertItem("&Print...", this , SLOT(print()));
file->insertSeparator();
file->insertItem( "&Close", this, SLOT(close()), CTRL+Key_X );
file->insertItem( "&Quit", qApp, SLOT( closeAllWindows() ), CTRL+Key_Q );
menuBar()->insertSeparator();
// tab menu
QPopupMenu * tab = new QPopupMenu( this );
menuBar()->insertItem( "&Tab", tab );
/*
tab->insertItem("Add &Segment Tab", this, SLOT(add_segment_tab()));
tab->insertItem("Add &Polyline Tab", this, SLOT(add_polyline_tab()));
#ifdef CGAL_USE_CORE
tab->insertItem("Add &Conic Tab", this, SLOT(add_conic_tab()));
tab->insertSeparator();
#endif
*/
示例14: createMenu
QPopupMenu* VCWidget::createMenu()
{
// Create edit menu here so that all submenus can be its children
/* DO NOT set this as the menu's parent object. Otherwise deleting this
thru the menu will crash the whole program. */
QPopupMenu* editMenu = new QPopupMenu(NULL);
// Foreground menu
QPopupMenu* fgMenu = new QPopupMenu(editMenu);
fgMenu->insertItem(QPixmap(QString(PIXMAPS) + QString("/color.png")),
"&Color...", KVCMenuForegroundColor);
fgMenu->insertItem(QPixmap(QString(PIXMAPS) + QString("/undo.png")),
"&Default", KVCMenuForegroundDefault);
// Background menu
QPopupMenu* bgMenu = new QPopupMenu(editMenu);
bgMenu->insertItem(QPixmap(QString(PIXMAPS) + QString("/color.png")),
"&Color...", KVCMenuBackgroundColor);
bgMenu->insertItem(QPixmap(QString(PIXMAPS) + QString("/image.png")),
"&Image...", KVCMenuBackgroundImage);
bgMenu->insertItem(QPixmap(QString(PIXMAPS) + QString("/undo.png")),
"&Default", KVCMenuBackgroundDefault);
// Font menu
QPopupMenu* fontMenu = new QPopupMenu(editMenu);
fontMenu->insertItem(QPixmap(QString(PIXMAPS) + QString("/fonts.png")),
"&Font...", KVCMenuFont);
fontMenu->insertItem(QPixmap(QString(PIXMAPS) + QString("/undo.png")),
"&Default", KVCMenuFontDefault);
// Frame menu
QPopupMenu* frameMenu = new QPopupMenu(editMenu);
frameMenu->insertItem(QPixmap(QString(PIXMAPS) + QString("/framesunken.png")),
"&Sunken", KVCMenuFrameSunken);
frameMenu->insertItem(QPixmap(QString(PIXMAPS) + QString("/frameraised.png")),
"&Raised", KVCMenuFrameRaised);
frameMenu->insertItem(QPixmap(QString(PIXMAPS) + QString("/framenone.png")),
"&None", KVCMenuFrameNone);
// Stacking order menu
QPopupMenu* stackMenu = new QPopupMenu(editMenu);
stackMenu->insertItem(QPixmap(QString(PIXMAPS) + QString("/up.png")),
"Bring to &Front", KVCMenuStackingRaise);
stackMenu->insertItem(QPixmap(QString(PIXMAPS) + QString("/down.png")),
"Send to &Back", KVCMenuStackingLower);
// Edit menu
editMenu->insertItem(QPixmap(QString(PIXMAPS) + QString("/editcut.png")),
"Cut", KVCMenuEditCut);
editMenu->insertItem(QPixmap(QString(PIXMAPS) + QString("/editcopy.png")),
"Copy", KVCMenuEditCopy);
editMenu->insertItem(QPixmap(QString(PIXMAPS) + QString("/editpaste.png")),
"Paste", KVCMenuEditPaste);
editMenu->insertItem(QPixmap(QString(PIXMAPS) + QString("/editdelete.png")),
"Delete", KVCMenuEditDelete);
editMenu->insertSeparator();
editMenu->insertItem(QPixmap(QString(PIXMAPS) + QString("/configure.png")),
"&Properties...", KVCMenuEditProperties);
editMenu->insertItem(QPixmap(QString(PIXMAPS) + QString("/editclear.png")),
"&Rename...", KVCMenuEditRename);
editMenu->setItemEnabled(KVCMenuEditCut, false);
editMenu->setItemEnabled(KVCMenuEditCopy, false);
editMenu->setItemEnabled(KVCMenuEditPaste, false);
editMenu->insertSeparator();
editMenu->insertItem("Background", bgMenu);
editMenu->insertItem("Foreground", fgMenu);
editMenu->insertItem("Font", fontMenu);
editMenu->insertItem("Frame", frameMenu);
editMenu->insertItem("Stacking Order", stackMenu);
connect(editMenu, SIGNAL(activated(int)),
this, SLOT(slotMenuCallback(int)));
connect(bgMenu, SIGNAL(activated(int)),
this, SLOT(slotMenuCallback(int)));
connect(fgMenu, SIGNAL(activated(int)),
this, SLOT(slotMenuCallback(int)));
connect(fontMenu, SIGNAL(activated(int)),
this, SLOT(slotMenuCallback(int)));
connect(frameMenu, SIGNAL(activated(int)),
this, SLOT(slotMenuCallback(int)));
connect(stackMenu, SIGNAL(activated(int)),
this, SLOT(slotMenuCallback(int)));
return editMenu;
}
示例15: strncmp
void
ReportManager::showRMBMenu(QListViewItem* lvi, const QPoint& pos, int,
bool& errors, bool& showReportTab)
{
ManagedReportInfo* mr = 0;
for (std::list<ManagedReportInfo*>::const_iterator mri = reports.begin();
mri != reports.end(); ++mri)
if ((*mri)->getBrowserEntry() == lvi)
mr = *mri;
// Generate a context popup menu.
QPopupMenu menu;
if (mr)
{
menu.insertItem(i18n("&Show Report"), 1);
menu.insertItem(i18n("&Generate Report"), 2);
menu.insertItem(i18n("&Edit Report Definition"), 3);
// The XML reports cannot be be viewed, so we disable the entry.
if (strncmp(mr->getProjectReport()->getType(), "XML", 3) == 0)
menu.setItemEnabled(1, false);
// The interactive reports can not be generated, so we disable the entry.
if (strncmp(mr->getProjectReport()->getType(), "Qt", 2) == 0)
menu.setItemEnabled(2, false);
}
menu.insertItem(i18n("E&xpand All"), 4);
menu.insertItem(i18n("S&hrink All"), 5);
menu.insertItem(i18n("&Generate Sub-Reports"), 6);
if (!lvi->firstChild())
{
menu.setItemEnabled(4, false);
menu.setItemEnabled(5, false);
}
if (lvi == qtReports || !lvi->firstChild()
|| (mr && strncmp(mr->getProjectReport()->getType(), "Qt", 2) == 0))
{
menu.setItemEnabled(6, false);
}
switch (menu.exec(pos))
{
case 1:
{
bool dummy;
errors = !showReport(lvi, dummy);
break;
}
case 2:
errors = !generateReport(lvi);
showReportTab = false;
break;
case 3:
editReport(mr->getProjectReport());
showReportTab = false;
break;
case 4:
expandLVI(lvi, true);
break;
case 5:
expandLVI(lvi, false);
break;
case 6:
errors = generateReports(lvi);
break;
default:
break;
}
}