本文整理汇总了C++中QMenuBar::setSeparator方法的典型用法代码示例。如果您正苦于以下问题:C++ QMenuBar::setSeparator方法的具体用法?C++ QMenuBar::setSeparator怎么用?C++ QMenuBar::setSeparator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMenuBar
的用法示例。
在下文中一共展示了QMenuBar::setSeparator方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QWidget
GLObjectWindow::GLObjectWindow( QWidget* parent, const char* name )
: QWidget( parent, name )
{
// Create nice frames to put around the OpenGL widgets
QFrame* f1 = new QFrame( this, "frame1" );
f1->setFrameStyle( QFrame::Sunken | QFrame::Panel );
f1->setLineWidth( 2 );
// Create an OpenGL widget
GLTexobj* c = new GLTexobj( f1, "glbox1");
// Create a menu
QPopupMenu *file = new QPopupMenu( this );
file->insertItem( "Toggle Animation", c, SLOT(toggleAnimation()),
CTRL+Key_A );
file->insertSeparator();
file->insertItem( "Exit", qApp, SLOT(quit()), CTRL+Key_Q );
// Create a menu bar
QMenuBar *m = new QMenuBar( this );
m->setSeparator( QMenuBar::InWindowsStyle );
m->insertItem("&File", file );
// Create the three sliders; one for each rotation axis
QSlider* x = new QSlider ( 0, 360, 60, 0, QSlider::Vertical, this, "xsl" );
x->setTickmarks( QSlider::Left );
connect( x, SIGNAL(valueChanged(int)), c, SLOT(setXRotation(int)) );
QSlider* y = new QSlider ( 0, 360, 60, 0, QSlider::Vertical, this, "ysl" );
y->setTickmarks( QSlider::Left );
connect( y, SIGNAL(valueChanged(int)), c, SLOT(setYRotation(int)) );
QSlider* z = new QSlider ( 0, 360, 60, 0, QSlider::Vertical, this, "zsl" );
z->setTickmarks( QSlider::Left );
connect( z, SIGNAL(valueChanged(int)), c, SLOT(setZRotation(int)) );
// Now that we have all the widgets, put them into a nice layout
// Put the sliders on top of each other
QVBoxLayout* vlayout = new QVBoxLayout( 20, "vlayout");
vlayout->addWidget( x );
vlayout->addWidget( y );
vlayout->addWidget( z );
// Put the GL widget inside the frame
QHBoxLayout* flayout1 = new QHBoxLayout( f1, 2, 2, "flayout1");
flayout1->addWidget( c, 1 );
// Top level layout, puts the sliders to the left of the frame/GL widget
QHBoxLayout* hlayout = new QHBoxLayout( this, 20, 20, "hlayout");
hlayout->setMenuBar( m );
hlayout->addLayout( vlayout );
hlayout->addWidget( f1, 1 );
}
示例2: CreateMenuBar
void SBookWidget::CreateMenuBar(QLayout *topLayout)
{
QMenuBar *menubar = new QMenuBar( this );
menubar->setSeparator( QMenuBar::InWindowsStyle );
QPopupMenu *file = new QPopupMenu;
file->insertItem( "&New File", this, SLOT(menuFileNew()) );
file->insertItem( "&Open", this, SLOT(menuFileOpen()),CTRL+Key_O );
file->insertSeparator();
file->insertItem( "&Save", this, SLOT(menuSave()),CTRL+Key_S );
file->insertItem( "Save &As ...", this, SLOT(menuSaveAs()));
file->insertItem( "E&xport ...", this, SLOT(menuExport()));
file->insertItem( "I&mport ...", this, SLOT(menuImport()));
file->insertSeparator();
file->insertItem( "&Print ...", this, SLOT(menuFilePrint()), CTRL+Key_P);
file->insertItem( "&Setup Label Printer ...", this, SLOT(menuFileSetupLabelPrinter()));
file->insertSeparator();
file->insertItem( "&Inspector", this, SLOT(menuShowInspector()),CTRL+SHIFT+Key_I);
file->insertItem( "&Exit", this, SLOT(menuFileExit()) );
menubar->insertItem( "&File", file );
/*************/
/* ENTRY */
/*************/
QPopupMenu *entry = new QPopupMenu;
entry->insertItem( "&New Entry", this, SLOT(menuEntryNew()),CTRL+Key_N );
entry->insertItem( "&Delete Entry", this, SLOT(menuEntryDelete()),CTRL+Key_D );
entry->insertItem( "&Find Entry", this, SLOT(menuFind()), CTRL+Key_F );
entry->insertSeparator();
entry->insertItem( "&Send Email", this, SLOT(sendEmail()), CTRL+Key_E );
entry->insertItem( "Print &Label ...", this, SLOT(menuFilePrintLabel()), CTRL+Key_L);
entry->insertItem( "Print Label 2 ...", this, SLOT(menuFilePrintLabel2()), CTRL+SHIFT+Key_L);
menubar->insertItem( "&Entry", entry);
/****************************************************************/
QPopupMenu *help = new QPopupMenu;
help->insertItem( "&About " APP_NAME " " APP_VERSION,
this, SLOT(menuAbout()) );
help->insertSeparator();
help->insertItem( "About &Qt" , this, SLOT(menuAboutQt()) );
menubar->insertItem( "&Help",help);
// ...and tell the layout about it.
topLayout->setMenuBar( menubar );
}
示例3: QWidget
GLObjectWindow::GLObjectWindow( QWidget* parent, const char* name )
: QWidget( parent, name )
{
// Create a menu
QPopupMenu *file = new QPopupMenu( this );
file->insertItem( "Exit", qApp, SLOT(quit()), CTRL+Key_Q );
// Create a menu bar
QMenuBar *m = new QMenuBar( this );
m->setSeparator( QMenuBar::InWindowsStyle );
m->insertItem("&File", file );
// Create a nice frame to put around the OpenGL widget
QFrame* f = new QFrame( this, "frame" );
f->setFrameStyle( QFrame::Sunken | QFrame::Panel );
f->setLineWidth( 2 );
// Create our OpenGL widget.
GLTeapots* c = new GLTeapots( f, "glteapots" );
// Check if we obtained an overlay
if ( !c->format().hasOverlay() ) {
QMessageBox::warning( 0, qApp->argv()[0],
"Failed to get an OpenGL overlay",
"Ok" );
}
// Now that we have all the widgets, put them into a nice layout
// Put the GL widget inside the frame
QHBoxLayout* flayout = new QHBoxLayout( f, 2, 2, "flayout");
flayout->addWidget( c, 1 );
// Top level layout
QVBoxLayout* hlayout = new QVBoxLayout( this, 20, 20, "hlayout");
hlayout->setMenuBar( m );
hlayout->addWidget( f, 1 );
}
示例4: QWidget
GLObjectWindow::GLObjectWindow( QWidget* parent, const char* name )
: QWidget( parent, name )
{
// Create a menu
file = new QPopupMenu( this );
file->setCheckable( TRUE );
file->insertItem( "Grab Frame Buffer", this, SLOT(grabFrameBuffer()) );
file->insertItem( "Render Pixmap", this, SLOT(makePixmap()) );
file->insertItem( "Render Pixmap Hidden", this, SLOT(makePixmapHidden()) );
file->insertSeparator();
fixMenuItemId = file->insertItem( "Use Fixed Pixmap Size", this,
SLOT(useFixedPixmapSize()) );
file->insertSeparator();
insertMenuItemId = file->insertItem( "Insert Pixmap Here", this,
SLOT(makePixmapForMenu()) );
file->insertSeparator();
file->insertItem( "Exit", qApp, SLOT(quit()), CTRL+Key_Q );
// Create a menu bar
QMenuBar *m = new QMenuBar( this );
m->setSeparator( QMenuBar::InWindowsStyle );
m->insertItem("&File", file );
// Create nice frames to put around the OpenGL widgets
QFrame* f1 = new QFrame( this, "frame1" );
f1->setFrameStyle( QFrame::Sunken | QFrame::Panel );
f1->setLineWidth( 2 );
// Create an OpenGL widget
c1 = new GLBox( f1, "glbox1");
// Create a label that can display the pixmap
lb = new QLabel( this, "pixlabel" );
lb->setFrameStyle( QFrame::Sunken | QFrame::Panel );
lb->setLineWidth( 2 );
lb->setAlignment( AlignCenter );
lb->setMargin( 0 );
lb->setIndent( 0 );
// Create the three sliders; one for each rotation axis
QSlider* x = new QSlider ( 0, 360, 60, 0, QSlider::Vertical, this, "xsl" );
x->setTickmarks( QSlider::Left );
connect( x, SIGNAL(valueChanged(int)), c1, SLOT(setXRotation(int)) );
QSlider* y = new QSlider ( 0, 360, 60, 0, QSlider::Vertical, this, "ysl" );
y->setTickmarks( QSlider::Left );
connect( y, SIGNAL(valueChanged(int)), c1, SLOT(setYRotation(int)) );
QSlider* z = new QSlider ( 0, 360, 60, 0, QSlider::Vertical, this, "zsl" );
z->setTickmarks( QSlider::Left );
connect( z, SIGNAL(valueChanged(int)), c1, SLOT(setZRotation(int)) );
// Now that we have all the widgets, put them into a nice layout
// Put the sliders on top of each other
QVBoxLayout* vlayout = new QVBoxLayout( 20, "vlayout");
vlayout->addWidget( x );
vlayout->addWidget( y );
vlayout->addWidget( z );
// Put the GL widget inside the frame
QHBoxLayout* flayout1 = new QHBoxLayout( f1, 2, 2, "flayout1");
flayout1->addWidget( c1, 1 );
// Top level layout, puts the sliders to the left of the frame/GL widget
QHBoxLayout* hlayout = new QHBoxLayout( this, 20, 20, "hlayout");
hlayout->setMenuBar( m );
hlayout->addLayout( vlayout );
hlayout->addWidget( f1, 1 );
hlayout->addWidget( lb, 1 );
}
示例5: QWidget
ExampleWidget::ExampleWidget( QWidget *parent, const char *name )
: QWidget( parent, name )
{
// Make the top-level layout; a vertical box to contain all widgets
// and sub-layouts.
QBoxLayout *topLayout = new QVBoxLayout( this, 5 );
// Create a menubar...
QMenuBar *menubar = new QMenuBar( this );
menubar->setSeparator( QMenuBar::InWindowsStyle );
QPopupMenu* popup;
popup = new QPopupMenu( this );
popup->insertItem( "&Quit", qApp, SLOT(quit()) );
menubar->insertItem( "&File", popup );
// ...and tell the layout about it.
topLayout->setMenuBar( menubar );
// Make an hbox that will hold a row of buttons.
QBoxLayout *buttons = new QHBoxLayout( topLayout );
int i;
for ( i = 1; i <= 4; i++ ) {
QPushButton* but = new QPushButton( this );
QString s;
s.sprintf( "Button %d", i );
but->setText( s );
// Set horizontal stretch factor to 10 to let the buttons
// stretch horizontally. The buttons will not stretch
// vertically, since bigWidget below will take up vertical
// stretch.
buttons->addWidget( but, 10 );
// (Actually, the result would have been the same with a
// stretch factor of 0; if no items in a layout have non-zero
// stretch, the space is divided equally between members.)
}
// Make another hbox that will hold a left-justified row of buttons.
QBoxLayout *buttons2 = new QHBoxLayout( topLayout );
QPushButton* but = new QPushButton( "Button five", this );
buttons2->addWidget( but );
but = new QPushButton( "Button 6", this );
buttons2->addWidget( but );
// Fill up the rest of the hbox with stretchable space, so that
// the buttons get their minimum width and are pushed to the left.
buttons2->addStretch( 10 );
// Make a big widget that will grab all space in the middle.
QMultiLineEdit *bigWidget = new QMultiLineEdit( this );
bigWidget->setText( "This widget will get all the remaining space" );
bigWidget->setFrameStyle( QFrame::Panel | QFrame::Plain );
// Set vertical stretch factor to 10 to let the bigWidget stretch
// vertically. It will stretch horizontally because there are no
// widgets beside it to take up horizontal stretch.
// topLayout->addWidget( bigWidget, 10 );
topLayout->addWidget( bigWidget );
// Make a grid that will hold a vertical table of QLabel/QLineEdit
// pairs next to a large QMultiLineEdit.
// Don't use hard-coded row/column numbers in QGridLayout, you'll
// regret it when you have to change the layout.
const int numRows = 3;
const int labelCol = 0;
const int linedCol = 1;
const int multiCol = 2;
// Let the grid-layout have a spacing of 10 pixels between
// widgets, overriding the default from topLayout.
QGridLayout *grid = new QGridLayout( topLayout, 0, 0, 10 );
int row;
for ( row = 0; row < numRows; row++ ) {
QLineEdit *ed = new QLineEdit( this );
// The line edit goes in the second column
grid->addWidget( ed, row, linedCol );
// Make a label that is a buddy of the line edit
QString s;
s.sprintf( "Line &%d", row+1 );
QLabel *label = new QLabel( ed, s, this );
// The label goes in the first column.
grid->addWidget( label, row, labelCol );
}
// The multiline edit will cover the entire vertical range of the
// grid (rows 0 to numRows) and stay in column 2.
QMultiLineEdit *med = new QMultiLineEdit( this );
grid->addMultiCellWidget( med, 0, -1, multiCol, multiCol );
// The labels will take the space they need. Let the remaining
// horizontal space be shared so that the multiline edit gets
// twice as much as the line edit.
grid->setColStretch( linedCol, 10 );
grid->setColStretch( multiCol, 20 );
//.........这里部分代码省略.........
示例6: QWidget
GLObjectWindow::GLObjectWindow( QWidget* parent, const char* name )
: QWidget( parent, name )
{
// Create top-level layout manager
QHBoxLayout* hlayout = new QHBoxLayout( this, 20, 20, "hlayout");
// Create a menu
QPopupMenu *file = new QPopupMenu();
file->insertItem( "Delete Left QGLWidget", this,
SLOT(deleteFirstWidget()) );
file->insertItem( "Exit", qApp, SLOT(quit()), CTRL+Key_Q );
// Create a menu bar
QMenuBar *m = new QMenuBar( this );
m->setSeparator( QMenuBar::InWindowsStyle );
m->insertItem("&File", file );
hlayout->setMenuBar( m );
// Create a layout manager for the sliders
QVBoxLayout* vlayout = new QVBoxLayout( 20, "vlayout");
hlayout->addLayout( vlayout );
// Create a nice frame to put around the openGL widget
QFrame* f = new QFrame( this, "frame" );
f->setFrameStyle( QFrame::Sunken | QFrame::Panel );
f->setLineWidth( 2 );
hlayout->addWidget( f, 1 );
// Create a layout manager for the openGL widget
QHBoxLayout* flayout = new QHBoxLayout( f, 2, 2, "flayout");
// Create an openGL widget
c1 = new GLBox( f, "glbox1");
c1->setMinimumSize( 50, 50 );
flayout->addWidget( c1, 1 );
flayout->activate();
// Create a nice frame to put around the second openGL widget
QFrame* f2 = new QFrame( this, "frame2" );
f2->setFrameStyle( QFrame::Sunken | QFrame::Panel );
f2->setLineWidth( 2 );
hlayout->addWidget( f2, 1 );
// Create a layout manager for the second openGL widget
QHBoxLayout* flayout2 = new QHBoxLayout( f2, 2, 2, "flayout2");
// Create another openGL widget which shares display lists with the first
c2 = new GLBox( f2, "glbox2", c1 );
c2->setMinimumSize( 50, 50 );
flayout2->addWidget( c2, 1 );
flayout2->activate();
// Create the three sliders; one for each rotation axis
QSlider* x = new QSlider ( 0, 360, 60, 0, QSlider::Vertical, this, "xsl" );
x->setTickmarks( QSlider::Left );
x->setMinimumSize( x->sizeHint() );
vlayout->addWidget( x );
QObject::connect( x, SIGNAL(valueChanged(int)),c1,SLOT(setXRotation(int)));
QObject::connect( x, SIGNAL(valueChanged(int)),c2,SLOT(setZRotation(int)));
QSlider* y = new QSlider ( 0, 360, 60, 0, QSlider::Vertical, this, "ysl" );
y->setTickmarks( QSlider::Left );
y->setMinimumSize( y->sizeHint() );
vlayout->addWidget( y );
QObject::connect( y, SIGNAL(valueChanged(int)),c1,SLOT(setYRotation(int)));
QObject::connect( y, SIGNAL(valueChanged(int)),c2,SLOT(setXRotation(int)));
QSlider* z = new QSlider ( 0, 360, 60, 0, QSlider::Vertical, this, "zsl" );
z->setTickmarks( QSlider::Left );
z->setMinimumSize( z->sizeHint() );
vlayout->addWidget( z );
QObject::connect( z, SIGNAL(valueChanged(int)),c1,SLOT(setZRotation(int)));
QObject::connect( z, SIGNAL(valueChanged(int)),c2,SLOT(setYRotation(int)));
// Start the geometry management
hlayout->activate();
}
示例7: QWidget
TxqPlot3DWindow::TxqPlot3DWindow( char *thisLabel, WindowType myWindow )
: QWidget( )
{
// set thisWindow so that all class members may access
thisWindow = myWindow;
// Set the title
setPalette( QPalette( Qt::lightGray ) );
setCaption(thisLabel);
setIconText(thisLabel);
// Create top-level layout manager
QHBoxLayout* hlayout = new QHBoxLayout( this, 20, 20, "hlayout");
// Create a popup menu containing Close
QPopupMenu *file = new QPopupMenu();
file->setPalette( QPalette( Qt::lightGray ) );
file->insertItem( "Close", this, SLOT( close() ), CTRL+Key_Q );
// Create a menu bar
QMenuBar *m = new QMenuBar( this );
m->setSeparator( QMenuBar::InWindowsStyle );
m->insertItem("&File", file );
hlayout->setMenuBar( m );
// Create a layout manager for the sliders
QVBoxLayout* vlayout = new QVBoxLayout( 20, "vlayout");
hlayout->addLayout( vlayout );
// Create a nice frame tp put around the openGL widget
QFrame* f = new QFrame( this, "frame" );
f->setFrameStyle( QFrame::Sunken | QFrame::Panel );
f->setLineWidth( 2 );
hlayout->addWidget( f, 1 );
// Create a layout manager for the openGL widget
QHBoxLayout* flayout = new QHBoxLayout( f, 2, 2, "flayout");
// Create an openGL widget
plot3D = new GLPlot3D( f, "glbox");
plot3D->setData(thisLabel, myWindow);
plot3D->setMinimumSize( 50, 50 );
flayout->addWidget( plot3D, 1 );
flayout->activate();
// Create the three sliders; one for each rotation axis
QSlider* x = new QSlider ( 0, 360, 60, 0, QSlider::Vertical, this, "xsl" );
x->setTickmarks( QSlider::Left );
x->setMinimumSize( x->sizeHint() );
vlayout->addWidget( x );
QObject::connect( x, SIGNAL(valueChanged(int)),plot3D,SLOT(setXRotation(int)) );
QSlider* y = new QSlider ( 0, 360, 60, 0, QSlider::Vertical, this, "ysl" );
y->setTickmarks( QSlider::Left );
y->setMinimumSize( y->sizeHint() );
vlayout->addWidget( y );
QObject::connect( y, SIGNAL(valueChanged(int)),plot3D,SLOT(setYRotation(int)) );
QSlider* z = new QSlider ( 0, 360, 60, 0, QSlider::Vertical, this, "zsl" );
z->setTickmarks( QSlider::Left );
z->setMinimumSize( z->sizeHint() );
vlayout->addWidget( z );
QObject::connect( z, SIGNAL(valueChanged(int)),plot3D,SLOT(setZRotation(int)) );
// create the slider for the eye translation
QSlider* t = new QSlider ( -15, -5, 1, -15, QSlider::Vertical, this, "tsl" );
t->setTickmarks( QSlider::Left );
t->setMinimumSize( x->sizeHint() );
vlayout->addWidget( t );
QObject::connect( t, SIGNAL(valueChanged(int)),plot3D,SLOT(setTranslation(int)) );
// Start the geometry management
hlayout->activate();
}
示例8: QWidget
WordsEdit::WordsEdit( QWidget *parent, const char *name, int win_num, ResourcesWin *res )
: QWidget( parent, name ,Qt::WDestructiveClose )
{
setCaption("WORDS.TOK Editor");
wordlist = new WordList();
winnum = win_num;
resources_win = res;
wordsfind = NULL;
Q3PopupMenu *file = new Q3PopupMenu( this );
Q_CHECK_PTR( file );
file->insertItem( "New", this, SLOT(new_file()) );
file->insertItem( "Open", this, SLOT(open_file()) );
file->insertItem( "Merge", this, SLOT(merge_file()) );
file->insertItem( "Save", this, SLOT(save_file()) );
file->insertItem( "Save As", this, SLOT(save_as_file()) );
file->insertSeparator();
file->insertItem( "Close", this, SLOT(close()) );
Q3PopupMenu *words = new Q3PopupMenu( this );
Q_CHECK_PTR( words );
words->insertItem( "Add word group", this, SLOT(add_group_cb()) );
words->insertItem( "Delete word group", this, SLOT(delete_group_cb()) );
words->insertItem( "Change group number", this, SLOT(change_group_number_cb()) );
words->insertSeparator();
words->insertItem( "Add word", this, SLOT(add_word_cb()) );
words->insertItem( "Delete word", this, SLOT(delete_word_cb()) );
words->insertSeparator();
words->insertItem( "Count word groups", this, SLOT(count_groups_cb()) );
words->insertItem( "Count words", this, SLOT(count_words_cb()) );
words->insertItem( "&Find...", this, SLOT(find_cb()) , Qt::CTRL+Qt::Key_F);
QMenuBar *menu = new QMenuBar(this);
Q_CHECK_PTR( menu );
menu->insertItem( "File", file );
menu->insertItem( "Words", words );
menu->setSeparator( QMenuBar::InWindowsStyle );
Q3BoxLayout *all = new Q3VBoxLayout(this,10);
QSplitter *split = new QSplitter(Qt::Horizontal,this);
QWidget *left = new QWidget(split);
Q3BoxLayout *lgroup = new Q3VBoxLayout(left,4);
QLabel *labelgroup = new QLabel("Word groups",left,"Word groups");
labelgroup->setAlignment(Qt::AlignCenter);
lgroup->addWidget(labelgroup);
listgroup = new Q3ListBox(left);
listgroup->setColumnMode (1);
listgroup->setMinimumSize(200,300);
connect( listgroup, SIGNAL(highlighted(int)), SLOT(select_group(int)) );
connect( listgroup, SIGNAL(selected(int)), SLOT(select_group(int)) );
lgroup->addWidget(listgroup);
QWidget *right = new QWidget(split);
Q3BoxLayout *lwords = new Q3VBoxLayout(right,4);
labelword = new QLabel("Word group",right,"Word group");
labelword->setAlignment(Qt::AlignCenter);
lwords->addWidget(labelword);
listwords = new Q3ListBox(right);
listwords->setColumnMode (1);
listwords->setMinimumSize(200,300);
connect( listwords, SIGNAL(highlighted(int)), SLOT(select_word(int)) );
connect( listwords, SIGNAL(selected(int)), SLOT(select_word(int)) );
lwords->addWidget(listwords);
lineword = new QLineEdit(right);
lineword->setEnabled(false);
connect( lineword, SIGNAL(returnPressed()), SLOT(do_add_word()) );
lwords->addWidget(lineword);
all->addWidget(split);
Q3BoxLayout *buttons = new Q3HBoxLayout(all,20);
add_group = new QPushButton("Add group",this);
connect( add_group, SIGNAL(clicked()), SLOT(add_group_cb()) );
buttons->addWidget(add_group);
delete_group = new QPushButton("Delete group",this);
connect( delete_group, SIGNAL(clicked()), SLOT(delete_group_cb()) );
buttons->addWidget(delete_group);
add_word = new QPushButton("Add word",this);
connect( add_word, SIGNAL(clicked()), SLOT(add_word_cb()) );
buttons->addWidget(add_word);
delete_word = new QPushButton("Delete word",this);
connect( delete_word, SIGNAL(clicked()), SLOT(delete_word_cb()) );
//.........这里部分代码省略.........