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