本文整理汇总了C++中QMenu类的典型用法代码示例。如果您正苦于以下问题:C++ QMenu类的具体用法?C++ QMenu怎么用?C++ QMenu使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QMenu类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: showContextMenu
void MainWindow::showContextMenu( QTableWidgetItem * item,bool itemClicked )
{
QMenu m ;
m.setFont( this->font() ) ;
int row = item->row() ;
QString mt = m_ui->tableWidget->item( row,1 )->text() ;
QString device = m_ui->tableWidget->item( row,0 )->text() ;
if( mt == "Nil" ){
connect( m.addAction( tr( "Mount" ) ),SIGNAL( triggered() ),this,SLOT( slotMount() ) ) ;
}else{
QString mp = QString( "/run/media/private/%1/" ).arg( utility::userName() ) ;
QString mp_1 = QString( "/home/%1/" ).arg( utility::userName() ) ;
if( mt.startsWith( mp ) || mt.startsWith( mp_1 ) ){
connect( m.addAction( tr( "Unmount" ) ),SIGNAL( triggered() ),this,SLOT( pbUmount() ) ) ;
m.addSeparator() ;
QString fs = m_ui->tableWidget->item( row,2 )->text() ;
if( fs != "encfs" ){
connect( m.addAction( tr( "Properties" ) ),SIGNAL( triggered() ),this,SLOT( volumeProperties() ) ) ;
m.addSeparator() ;
}
m_sharedFolderPath = utility::sharedMountPointPath( mt ) ;
if( m_sharedFolderPath.isEmpty() ){
connect( m.addAction( tr( "Open Folder" ) ),SIGNAL( triggered() ),
this,SLOT( slotOpenFolder() ) ) ;
}else{
connect( m.addAction( tr( "Open Private Folder" ) ),SIGNAL( triggered() ),
this,SLOT( slotOpenFolder() ) ) ;
connect( m.addAction( tr( "Open Shared Folder" ) ),SIGNAL( triggered() ),
this,SLOT( slotOpenSharedFolder() ) ) ;
}
}else{
m_sharedFolderPath = utility::sharedMountPointPath( mt ) ;
if( m_sharedFolderPath.isEmpty() ){
if( utility::pathIsReadable( mt ) ){
connect( m.addAction( tr( "Properties" ) ),SIGNAL( triggered() ),this,SLOT( volumeProperties() ) ) ;
m.addSeparator() ;
connect( m.addAction( tr( "Open Folder" ) ),SIGNAL( triggered() ),
this,SLOT( slotOpenFolder() ) ) ;
}else{
connect( m.addAction( tr( "Properties" ) ),SIGNAL( triggered() ),this,SLOT( volumeProperties() ) ) ;
}
}else{
connect( m.addAction( tr( "Properties" ) ),SIGNAL( triggered() ),this,SLOT( volumeProperties() ) ) ;
m.addSeparator() ;
connect( m.addAction( tr( "Open Shared Folder" ) ),SIGNAL( triggered() ),
this,SLOT( slotOpenSharedFolder() ) ) ;
}
}
}
m.addSeparator() ;
m.addAction( tr( "Close Menu" ) ) ;
if( itemClicked ){
m.exec( QCursor::pos() ) ;
}else{
QPoint p = this->pos() ;
int x = p.x() + 100 + m_ui->tableWidget->columnWidth( 0 ) ;
int y = p.y() + 50 + m_ui->tableWidget->rowHeight( 0 ) * item->row() ;
p.setX( x ) ;
p.setY( y ) ;
m.exec( p ) ;
}
}
示例2: QWidget
BlockingClient::BlockingClient(QWidget *parent)
: QWidget(parent)
{
hostLabel = new QLabel(tr("&Server name:"));
portLabel = new QLabel(tr("S&erver port:"));
// find out which IP to connect to
QString ipAddress;
QList<QHostAddress> ipAddressesList = QNetworkInterface::allAddresses();
// use the first non-localhost IPv4 address
for (int i = 0; i < ipAddressesList.size(); ++i) {
if (ipAddressesList.at(i) != QHostAddress::LocalHost &&
ipAddressesList.at(i).toIPv4Address()) {
ipAddress = ipAddressesList.at(i).toString();
break;
}
}
// if we did not find one, use IPv4 localhost
if (ipAddress.isEmpty())
ipAddress = QHostAddress(QHostAddress::LocalHost).toString();
hostLineEdit = new QLineEdit(ipAddress);
portLineEdit = new QLineEdit;
portLineEdit->setValidator(new QIntValidator(1, 65535, this));
#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR)
Qt::InputMethodHint hints = Qt::ImhDigitsOnly;
portLineEdit->setInputMethodHints(hints);
#endif
hostLabel->setBuddy(hostLineEdit);
portLabel->setBuddy(portLineEdit);
statusLabel = new QLabel(tr("This examples requires that you run the "
"Fortune Server example as well."));
statusLabel->setWordWrap(true);
#ifdef Q_OS_SYMBIAN
QMenu *menu = new QMenu(this);
fortuneAction = menu->addAction(tr("Get Fortune"));
fortuneAction->setVisible(false);
QAction *optionsAction = new QAction(tr("Options"), this);
optionsAction->setMenu(menu);
optionsAction->setSoftKeyRole(QAction::PositiveSoftKey);
addAction(optionsAction);
exitAction = new QAction(tr("Exit"), this);
exitAction->setSoftKeyRole(QAction::NegativeSoftKey);
addAction(exitAction);
connect(fortuneAction, SIGNAL(triggered()), this, SLOT(requestNewFortune()));
connect(exitAction, SIGNAL(triggered()), this, SLOT(close()));
#else
getFortuneButton = new QPushButton(tr("Get Fortune"));
getFortuneButton->setDefault(true);
getFortuneButton->setEnabled(false);
quitButton = new QPushButton(tr("Quit"));
buttonBox = new QDialogButtonBox;
buttonBox->addButton(getFortuneButton, QDialogButtonBox::ActionRole);
buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole);
connect(getFortuneButton, SIGNAL(clicked()), this, SLOT(requestNewFortune()));
connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));
#endif
connect(hostLineEdit, SIGNAL(textChanged(QString)),
this, SLOT(enableGetFortuneButton()));
connect(portLineEdit, SIGNAL(textChanged(QString)),
this, SLOT(enableGetFortuneButton()));
//! [0]
connect(&thread, SIGNAL(newFortune(QString)),
this, SLOT(showFortune(QString)));
//! [0] //! [1]
connect(&thread, SIGNAL(error(int,QString)),
this, SLOT(displayError(int,QString)));
//! [1]
QGridLayout *mainLayout = new QGridLayout;
mainLayout->addWidget(hostLabel, 0, 0);
mainLayout->addWidget(hostLineEdit, 0, 1);
mainLayout->addWidget(portLabel, 1, 0);
mainLayout->addWidget(portLineEdit, 1, 1);
mainLayout->addWidget(statusLabel, 2, 0, 1, 2);
#ifndef Q_OS_SYMBIAN
mainLayout->addWidget(buttonBox, 3, 0, 1, 2);
#endif
setLayout(mainLayout);
setWindowTitle(tr("Blocking Fortune Client"));
portLineEdit->setFocus();
}
示例3: QSystemTrayIcon
void BitcoinGUI::createTrayIcon()
{
QMenu *trayIconMenu;
#ifndef Q_OS_MAC
trayIcon = new QSystemTrayIcon(this);
trayIconMenu = new QMenu(this);
trayIcon->setContextMenu(trayIconMenu);
trayIcon->setToolTip(tr("GorillaBucks client"));
trayIcon->setIcon(QIcon(":/icons/toolbar"));
connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason)));
trayIcon->show();
#else
// Note: On Mac, the dock icon is used to provide the tray's functionality.
MacDockIconHandler *dockIconHandler = MacDockIconHandler::instance();
dockIconHandler->setMainWindow((QMainWindow *)this);
trayIconMenu = dockIconHandler->dockMenu();
#endif
// Configuration of the tray icon (or dock icon) icon menu
trayIconMenu->addAction(toggleHideAction);
trayIconMenu->addSeparator();
trayIconMenu->addAction(receiveCoinsAction);
trayIconMenu->addAction(sendCoinsAction);
trayIconMenu->addSeparator();
trayIconMenu->addAction(signMessageAction);
trayIconMenu->addAction(verifyMessageAction);
trayIconMenu->addSeparator();
trayIconMenu->addAction(optionsAction);
trayIconMenu->addAction(openRPCConsoleAction);
#ifndef Q_OS_MAC // This is built-in on Mac
trayIconMenu->addSeparator();
trayIconMenu->addAction(quitAction);
#endif
notificator = new Notificator(qApp->applicationName(), trayIcon);
}
示例4: ATopLevelWindow
MailEditorMainWindow::MailEditorMainWindow(ATopLevelWindowsContainer* parent, AddressBookModel& abModel,
IMailProcessor& mailProcessor, bool editMode) :
ATopLevelWindow(parent),
ui(new Ui::MailEditorWindow()),
ABModel(abModel),
MailProcessor(mailProcessor),
FontCombo(nullptr),
EditMode(editMode)
{
ui->setupUi(this);
/** Disable these toolbars by default. They should be showed up on demand, when given action will
be trigerred.
*/
ui->fileAttachementToolBar->hide();
ui->moneyAttachementToolBar->hide();
ui->editToolBar->hide();
ui->adjustToolbar->hide();
ui->formatToolBar->hide();
MoneyAttachement = new TMoneyAttachementWidget(ui->moneyAttachementToolBar);
ui->moneyAttachementToolBar->addWidget(MoneyAttachement);
FileAttachment = new TFileAttachmentWidget(ui->fileAttachementToolBar, editMode);
ui->fileAttachementToolBar->addWidget(FileAttachment);
MailFields = new MailFieldsWidget(*this, *ui->actionSend, abModel, editMode);
/// Initially only basic mail fields (To: and Subject:) should be visible
MailFields->showCcControls(false);
MailFields->showBccControls(false);
ui->mailFieldsToolBar->addWidget(MailFields);
connect(MailFields, SIGNAL(subjectChanged(QString)), this, SLOT(onSubjectChanged(QString)));
connect(MailFields, SIGNAL(recipientListChanged()), this, SLOT(onRecipientListChanged()));
connect(FileAttachment, SIGNAL(attachmentListChanged()), this, SLOT(onAttachmentListChanged()));
if(editMode)
{
/** Supplement definition of mailFieldSelectorToolbar since Qt Creator doesn't support putting
into its context dedicated controls (like preconfigured toolbutton).
Setup local menu for 'actionMailFields' toolButton (used to enable/disable additional mail
field selection).
*/
QMenu* mailFieldsMenu = new QMenu(this);
mailFieldsMenu->addAction(ui->actionFrom);
mailFieldsMenu->addAction(ui->actionCC);
mailFieldsMenu->addAction(ui->actionBCC);
/// Update state of sub-menu commands.
ui->actionBCC->setChecked(MailFields->isFieldVisible(MailFieldsWidget::BCC_FIELDS));
ui->actionCC->setChecked(MailFields->isFieldVisible(MailFieldsWidget::CC_FIELD));
ui->actionFrom->setChecked(MailFields->isFieldVisible(MailFieldsWidget::FROM_FIELD));
ui->actionMailFields->setMenu(mailFieldsMenu);
ui->mainToolBar->insertAction(ui->actionShowFormatOptions, ui->actionMailFields);
}
setupEditorCommands();
ui->messageEdit->setFocus();
fontChanged(ui->messageEdit->font());
colorChanged(ui->messageEdit->textColor());
alignmentChanged(ui->messageEdit->alignment());
QString subject = MailFields->getSubject();
onSubjectChanged(subject);
/// Clear modified flag
ui->messageEdit->document()->setModified(false);
setWindowModified(ui->messageEdit->document()->isModified());
ui->actionSave->setEnabled(ui->messageEdit->document()->isModified());
ui->actionUndo->setEnabled(ui->messageEdit->document()->isUndoAvailable());
ui->actionRedo->setEnabled(ui->messageEdit->document()->isRedoAvailable());
/// Setup command update ui related to 'save' option activity control and window modify marker.
connect(ui->messageEdit->document(), SIGNAL(modificationChanged(bool)), ui->actionSave,
SLOT(setEnabled(bool)));
connect(ui->messageEdit->document(), SIGNAL(modificationChanged(bool)), this,
SLOT(setWindowModified(bool)));
connect(ui->messageEdit, SIGNAL(addAttachments(QStringList)), this, SLOT(onAddAttachments(QStringList)));
#ifndef QT_NO_CLIPBOARD
connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(onClipboardDataChanged()));
#endif
toggleReadOnlyMode();
}
示例5: createMenus
void MainWindow::createMenus()
{
QMenu *menu;
QAction *action;
menu = getStandardMenu(FileMenu);
menu->addAction(standardAction(New));
menu->addAction(standardAction(Print));
menu->addSeparator();
menu->addAction(standardAction(Exit));
menu = getStandardMenu(EditMenu);
menu->addAction(standardAction(Undo));
menu->addAction(standardAction(Redo));
menu->addSeparator();
menu->addAction(standardAction(Cut));
menu->addAction(standardAction(Copy));
menu->addAction(standardAction(Paste));
menu->addSeparator();
menu->addAction(standardAction(Delete));
addStandardMenu(HelpMenu);
}
示例6: QMenu
void MainWindow::createMenus()
{
QMenuBar *bar = this->menuBar();
QMenu *fileMenu = new QMenu(tr("&File"), bar);
fileMenu->addAction(newPostAct);
fileMenu->addAction(openPostAct);
fileMenu->addAction(closePostAct);
fileMenu->addSeparator();
fileMenu->addAction(savePostAct);
fileMenu->addAction(saveAsPostAct);
fileMenu->addSeparator();
fileMenu->addAction(exitAct);
bar->addMenu(fileMenu);
QMenu *editMenu = new QMenu(tr("&Edit"), bar);
editMenu->addAction(undoAct);
editMenu->addAction(redoAct);
editMenu->addSeparator();
editMenu->addAction(cutAct);
editMenu->addAction(copyAct);
editMenu->addAction(pasteAct);
bar->addMenu(editMenu);
QMenu *formatMenu = new QMenu(tr("F&ormat"), bar);
formatMenu->addAction(textFontAct);
formatMenu->addAction(textColorAct);
formatMenu->addAction(textBackgroundColorAct);
formatMenu->addSeparator();
QMenu *alignMenu = new QMenu(tr("Alignment"), formatMenu);
if(QApplication::isLeftToRight()) {
alignMenu->addAction(alignLeftAct);
alignMenu->addAction(alignCenterAct);
alignMenu->addAction(alignRightAct);
} else {
alignMenu->addAction(alignRightAct);
alignMenu->addAction(alignCenterAct);
alignMenu->addAction(alignLeftAct);
}
alignMenu->addAction(alignJustifyAct);
formatMenu->addMenu(alignMenu);
bar->addMenu(formatMenu);
QMenu *insertMenu = new QMenu(tr("&Insert"), bar);
QMenu *listMenu = new QMenu(tr("List"), insertMenu);
listMenu->addAction(bulletListAct);
listMenu->addAction(numberedListAct);
listMenu->addSeparator();
listMenu->addAction(indentMoreAct);
listMenu->addAction(indentLessAct);
insertMenu->addMenu(listMenu);
QMenu *tableMenu = createTableMenu(insertMenu);
insertMenu->addMenu(tableMenu);
bar->addMenu(insertMenu);
QMenu *toolMenu = new QMenu(tr("&Tools"), bar);
toolMenu->addAction(pluginAct);
bar->addMenu(toolMenu);
bar->addSeparator();
QMenu *helpMenu = new QMenu(tr("Help"), bar);
helpMenu->addAction(helpAct);
helpMenu->addAction(aboutAct);
bar->addMenu(helpMenu);
}
示例7: QgsRendererV2Widget
QgsCategorizedSymbolRendererV2Widget::QgsCategorizedSymbolRendererV2Widget( QgsVectorLayer* layer, QgsStyleV2* style, QgsFeatureRendererV2* renderer )
: QgsRendererV2Widget( layer, style )
, mRenderer( nullptr )
, mModel( nullptr )
{
// try to recognize the previous renderer
// (null renderer means "no previous renderer")
if ( renderer )
{
mRenderer = QgsCategorizedSymbolRendererV2::convertFromRenderer( renderer );
}
if ( !mRenderer )
{
mRenderer = new QgsCategorizedSymbolRendererV2( "", QgsCategoryList() );
}
QString attrName = mRenderer->classAttribute();
mOldClassificationAttribute = attrName;
// setup user interface
setupUi( this );
mExpressionWidget->setLayer( mLayer );
cboCategorizedColorRamp->populate( mStyle );
int randomIndex = cboCategorizedColorRamp->findText( tr( "Random colors" ) );
if ( randomIndex != -1 )
{
cboCategorizedColorRamp->setCurrentIndex( randomIndex );
}
// set project default color ramp
QString defaultColorRamp = QgsProject::instance()->readEntry( "DefaultStyles", "/ColorRamp", "" );
if ( defaultColorRamp != "" )
{
int index = cboCategorizedColorRamp->findText( defaultColorRamp, Qt::MatchCaseSensitive );
if ( index >= 0 )
cboCategorizedColorRamp->setCurrentIndex( index );
}
mCategorizedSymbol = QgsSymbolV2::defaultSymbol( mLayer->geometryType() );
mModel = new QgsCategorizedSymbolRendererV2Model( this );
mModel->setRenderer( mRenderer );
// update GUI from renderer
updateUiFromRenderer();
viewCategories->setModel( mModel );
viewCategories->resizeColumnToContents( 0 );
viewCategories->resizeColumnToContents( 1 );
viewCategories->resizeColumnToContents( 2 );
viewCategories->setStyle( new QgsCategorizedSymbolRendererV2ViewStyle( viewCategories->style() ) );
connect( mModel, SIGNAL( rowsMoved() ), this, SLOT( rowsMoved() ) );
connect( mExpressionWidget, SIGNAL( fieldChanged( QString ) ), this, SLOT( categoryColumnChanged( QString ) ) );
connect( viewCategories, SIGNAL( doubleClicked( const QModelIndex & ) ), this, SLOT( categoriesDoubleClicked( const QModelIndex & ) ) );
connect( viewCategories, SIGNAL( customContextMenuRequested( const QPoint& ) ), this, SLOT( contextMenuViewCategories( const QPoint& ) ) );
connect( btnChangeCategorizedSymbol, SIGNAL( clicked() ), this, SLOT( changeCategorizedSymbol() ) );
connect( btnAddCategories, SIGNAL( clicked() ), this, SLOT( addCategories() ) );
connect( btnDeleteCategories, SIGNAL( clicked() ), this, SLOT( deleteCategories() ) );
connect( btnDeleteAllCategories, SIGNAL( clicked() ), this, SLOT( deleteAllCategories() ) );
connect( btnAddCategory, SIGNAL( clicked() ), this, SLOT( addCategory() ) );
connect( cbxInvertedColorRamp, SIGNAL( toggled( bool ) ), this, SLOT( applyColorRamp() ) );
connect( cboCategorizedColorRamp, SIGNAL( currentIndexChanged( int ) ), this, SLOT( applyColorRamp() ) );
connect( cboCategorizedColorRamp, SIGNAL( sourceRampEdited() ), this, SLOT( applyColorRamp() ) );
connect( mButtonEditRamp, SIGNAL( clicked() ), cboCategorizedColorRamp, SLOT( editSourceRamp() ) );
// menus for data-defined rotation/size
QMenu* advMenu = new QMenu;
advMenu->addAction( tr( "Match to saved symbols" ), this, SLOT( matchToSymbolsFromLibrary() ) );
advMenu->addAction( tr( "Match to symbols from file..." ), this, SLOT( matchToSymbolsFromXml() ) );
advMenu->addAction( tr( "Symbol levels..." ), this, SLOT( showSymbolLevels() ) );
btnAdvanced->setMenu( advMenu );
mExpressionWidget->registerGetExpressionContextCallback( &_getExpressionContext, this );
}
示例8: menuBar
void MainWindow::createMenuBar()
{
QMenu *game = menuBar()->addMenu("&Game");
QMenu *gnew = game->addMenu("&New");
QMenu *help = menuBar()->addMenu("&Help");
gnew->addAction("&Easy", this, SLOT(newGameEasy()));
gnew->addAction("&Normal", this, SLOT(newGameNormal()));
gnew->addAction("&Hard", this, SLOT(newGameHard()));
gnew->addAction("E&xpert", this, SLOT(newGameExpert()));
game->addSeparator();
game->addAction("E&xit", qApp, SLOT(quit()));
help->addAction("&About", qApp, SLOT(aboutQt()));
}
示例9: QDialog
Dialog::Dialog(QWidget *parent) :
QDialog(parent, Qt::Tool | Qt::WindowStaysOnTopHint | Qt::CustomizeWindowHint),
ui(new Ui::Dialog),
mSettings(new LxQt::Settings("lxqt-runner", this)),
mGlobalShortcut(0),
mLockCascadeChanges(false),
mConfigureDialog(0)
{
ui->setupUi(this);
setWindowTitle("LXQt Runner");
setAttribute(Qt::WA_TranslucentBackground);
connect(LxQt::Settings::globalSettings(), SIGNAL(iconThemeChanged()), this, SLOT(update()));
connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(hide()));
connect(mSettings, SIGNAL(settingsChanged()), this, SLOT(applySettings()));
ui->commandEd->installEventFilter(this);
connect(ui->commandEd, SIGNAL(textChanged(QString)), this, SLOT(setFilter(QString)));
connect(ui->commandEd, SIGNAL(returnPressed()), this, SLOT(runCommand()));
mCommandItemModel = new CommandItemModel(this);
ui->commandList->installEventFilter(this);
ui->commandList->setModel(mCommandItemModel);
ui->commandList->setEditTriggers(QAbstractItemView::NoEditTriggers);
connect(ui->commandList, SIGNAL(clicked(QModelIndex)), this, SLOT(runCommand()));
setFilter("");
dataChanged();
ui->commandList->setItemDelegate(new LxQt::HtmlDelegate(QSize(32, 32), ui->commandList));
// Popup menu ...............................
QAction *a = new QAction(XdgIcon::fromTheme("configure"), tr("Configure"), this);
connect(a, SIGNAL(triggered()), this, SLOT(showConfigDialog()));
addAction(a);
a = new QAction(XdgIcon::fromTheme("edit-clear-history"), tr("Clear History"), this);
connect(a, SIGNAL(triggered()), mCommandItemModel, SLOT(clearHistory()));
addAction(a);
mPowerManager = new LxQt::PowerManager(this);
addActions(mPowerManager->availableActions());
mScreenSaver = new LxQt::ScreenSaver(this);
addActions(mScreenSaver->availableActions());
setContextMenuPolicy(Qt::ActionsContextMenu);
QMenu *menu = new QMenu(this);
menu->addActions(actions());
ui->actionButton->setMenu(menu);
ui->actionButton->setIcon(XdgIcon::fromTheme("configure"));
// End of popup menu ........................
applySettings();
connect(QApplication::desktop(), SIGNAL(screenCountChanged(int)), SLOT(realign()));
connect(QApplication::desktop(), SIGNAL(workAreaResized(int)), SLOT(realign()));
connect(mGlobalShortcut, SIGNAL(activated()), this, SLOT(showHide()));
connect(mGlobalShortcut, SIGNAL(shortcutChanged(QString,QString)), this, SLOT(shortcutChanged(QString,QString)));
resize(mSettings->value("dialog/width", 400).toInt(), size().height());
// TEST
connect(mCommandItemModel, SIGNAL(layoutChanged()), this, SLOT(dataChanged()));
}
示例10: QMainWindow
MainWindow::MainWindow()
: QMainWindow()
, m_view(new SvgView)
{
QMenu *fileMenu = new QMenu(tr("&File"), this);
QAction *openAction = fileMenu->addAction(tr("&Open..."));
openAction->setShortcut(QKeySequence(tr("Ctrl+O")));
QAction *quitAction = fileMenu->addAction(tr("E&xit"));
quitAction->setShortcuts(QKeySequence::Quit);
menuBar()->addMenu(fileMenu);
QMenu *viewMenu = new QMenu(tr("&View"), this);
m_backgroundAction = viewMenu->addAction(tr("&Background"));
m_backgroundAction->setEnabled(false);
m_backgroundAction->setCheckable(true);
m_backgroundAction->setChecked(false);
connect(m_backgroundAction, SIGNAL(toggled(bool)), m_view, SLOT(setViewBackground(bool)));
m_outlineAction = viewMenu->addAction(tr("&Outline"));
m_outlineAction->setEnabled(false);
m_outlineAction->setCheckable(true);
m_outlineAction->setChecked(true);
connect(m_outlineAction, SIGNAL(toggled(bool)), m_view, SLOT(setViewOutline(bool)));
menuBar()->addMenu(viewMenu);
QMenu *rendererMenu = new QMenu(tr("&Renderer"), this);
m_nativeAction = rendererMenu->addAction(tr("&Native"));
m_nativeAction->setCheckable(true);
m_nativeAction->setChecked(true);
#ifndef QT_NO_OPENGL
m_glAction = rendererMenu->addAction(tr("&OpenGL"));
m_glAction->setCheckable(true);
#endif
m_imageAction = rendererMenu->addAction(tr("&Image"));
m_imageAction->setCheckable(true);
#ifndef QT_NO_OPENGL
rendererMenu->addSeparator();
m_highQualityAntialiasingAction = rendererMenu->addAction(tr("&High Quality Antialiasing"));
m_highQualityAntialiasingAction->setEnabled(false);
m_highQualityAntialiasingAction->setCheckable(true);
m_highQualityAntialiasingAction->setChecked(false);
connect(m_highQualityAntialiasingAction, SIGNAL(toggled(bool)), m_view, SLOT(setHighQualityAntialiasing(bool)));
#endif
QActionGroup *rendererGroup = new QActionGroup(this);
rendererGroup->addAction(m_nativeAction);
#ifndef QT_NO_OPENGL
rendererGroup->addAction(m_glAction);
#endif
rendererGroup->addAction(m_imageAction);
menuBar()->addMenu(rendererMenu);
connect(openAction, SIGNAL(triggered()), this, SLOT(openFile()));
connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
connect(rendererGroup, SIGNAL(triggered(QAction*)),
this, SLOT(setRenderer(QAction*)));
setCentralWidget(m_view);
setWindowTitle(tr("SVG Viewer"));
}
示例11: on_treeView_customContextMenuRequested
void MainWindow::on_treeView_customContextMenuRequested(const QPoint &pt)
{
QPoint globalPt = ui->treeView->mapToGlobal(pt);
QModelIndex index = ui->treeView->indexAt(pt);
QMenu menu;
if (index.isValid())
{
on_treeView_clicked(index);
ProjectItem* item = (ProjectItem*) Workspace::Instance.GetProjectsModel()->itemFromIndex(index);
switchToAct->setEnabled(!item->IsSelected());
menu.addAction(switchToAct);
if(!item->IsDocument())
{
menu.addAction(addImageAct);
menu.addSeparator();
menu.addAction(saveProjctAct);
menu.addAction(closeProjectAct);
menu.addSeparator();
}
else
{
menu.addAction(removeImageAct);
menu.addSeparator();
}
}
menu.addAction(newProjectAct);
menu.addAction(openProjectAct);
menu.addSeparator();
menu.addAction(saveAllAct);
menu.addAction(closeAllAct);
menu.exec(globalPt);
}
开发者ID:imilos,项目名称:Application-of-pattern-recognition-algorithms-in-neutron-dosimetry,代码行数:39,代码来源:mainwindow.cpp
示例12: Q_UNUSED
// ----------------------------------------------------------------------------
bool qMRMLTreeViewEventTranslator::translateEvent(QObject *Object,
QEvent *Event,
int EventType,
bool &Error)
{
Q_UNUSED(Error);
qMRMLTreeView* treeView = NULL;
for(QObject* test = Object; treeView == NULL && test != NULL; test = test->parent())
{
treeView = qobject_cast<qMRMLTreeView*>(test);
}
// qMRMLTreeView* treeView = qobject_cast<qMRMLTreeView*>(Object);
if(!treeView)
{
return false;
}
// For the custom action when we have a right click
QMenu* menu = NULL;
for(QObject* test = Object; menu == NULL && test != NULL ; test = test->parent())
{
menu = qobject_cast<QMenu*>(test);
}
if (menu)
{
if(Event->type() == QEvent::KeyPress)
{
QKeyEvent* e = static_cast<QKeyEvent*>(Event);
if(e->key() == Qt::Key_Enter)
{
QAction* action = menu->activeAction();
if(action)
{
QString which = action->objectName();
if(which == QString::null)
{
which = action->text();
}
if (which != "Rename" && which != "Delete" )
{
emit recordEvent(menu, "activate", which);
}
}
}
}
if(Event->type() == QEvent::MouseButtonRelease)
{
QMouseEvent* e = static_cast<QMouseEvent*>(Event);
if(e->button() == Qt::LeftButton)
{
QAction* action = menu->actionAt(e->pos());
if (action && !action->menu())
{
QString which = action->objectName();
if(which == QString::null)
{
which = action->text();
}
if (which != "Rename" && which != "Delete" )
{
emit recordEvent(menu, "activate", which);
}
}
}
}
return true;
}
// We want to stop the action on the QDialog when we are renaming
// and let passed the action for the "set_current".
QInputDialog* dialog = NULL;
for(QObject* test = Object; dialog == NULL && test != NULL; test = test->parent())
{
dialog = qobject_cast<QInputDialog*>(test);
if(dialog)
{
// block actions on the QInputDialog
return true;
}
}
if(Event->type() == QEvent::Enter && Object == treeView)
{
if(this->CurrentObject != Object)
{
if(this->CurrentObject)
{
disconnect(this->CurrentObject, 0, this, 0);
}
this->CurrentObject = Object;
connect(treeView, SIGNAL(destroyed(QObject*)),
this, SLOT(onDestroyed(QObject*)));
connect(treeView, SIGNAL(currentNodeRenamed(QString)),
this, SLOT(onCurrentNodeRenamed(QString)));
// Can be better to do it on the model to recover the QModelIndex
connect(treeView, SIGNAL(currentNodeDeleted(const QModelIndex&)),
//.........这里部分代码省略.........
示例13: QAction
void CQTOpenGLLuaMainWindow::CreateEditActions() {
QIcon cEditUndoIcon;
cEditUndoIcon.addPixmap(QPixmap(m_pcMainWindow->GetIconDir() + "/undo.png"));
m_pcEditUndoAction = new QAction(cEditUndoIcon, tr("&Undo"), this);
m_pcEditUndoAction->setToolTip(tr("Undo last operation"));
m_pcEditUndoAction->setStatusTip(tr("Undo last operation"));
m_pcEditUndoAction->setShortcut(QKeySequence::Undo);
connect(m_pcEditUndoAction, SIGNAL(triggered()),
m_pcCodeEditor, SLOT(undo()));
QIcon cEditRedoIcon;
cEditRedoIcon.addPixmap(QPixmap(m_pcMainWindow->GetIconDir() + "/redo.png"));
m_pcEditRedoAction = new QAction(cEditRedoIcon, tr("&Redo"), this);
m_pcEditRedoAction->setToolTip(tr("Redo last operation"));
m_pcEditRedoAction->setStatusTip(tr("Redo last operation"));
m_pcEditRedoAction->setShortcut(QKeySequence::Redo);
connect(m_pcEditRedoAction, SIGNAL(triggered()),
m_pcCodeEditor, SLOT(redo()));
QIcon cEditCopyIcon;
cEditCopyIcon.addPixmap(QPixmap(m_pcMainWindow->GetIconDir() + "/copy.png"));
m_pcEditCopyAction = new QAction(cEditCopyIcon, tr("&Copy"), this);
m_pcEditCopyAction->setToolTip(tr("Copy selected text into clipboard"));
m_pcEditCopyAction->setStatusTip(tr("Copy selected text into clipboard"));
m_pcEditCopyAction->setShortcut(QKeySequence::Copy);
connect(m_pcEditCopyAction, SIGNAL(triggered()),
m_pcCodeEditor, SLOT(copy()));
QIcon cEditCutIcon;
cEditCutIcon.addPixmap(QPixmap(m_pcMainWindow->GetIconDir() + "/cut.png"));
m_pcEditCutAction = new QAction(cEditCutIcon, tr("&Cut"), this);
m_pcEditCutAction->setToolTip(tr("Move selected text into clipboard"));
m_pcEditCutAction->setStatusTip(tr("Move selected text into clipboard"));
m_pcEditCutAction->setShortcut(QKeySequence::Cut);
connect(m_pcEditCutAction, SIGNAL(triggered()),
m_pcCodeEditor, SLOT(cut()));
QIcon cEditPasteIcon;
cEditPasteIcon.addPixmap(QPixmap(m_pcMainWindow->GetIconDir() + "/paste.png"));
m_pcEditPasteAction = new QAction(cEditPasteIcon, tr("&Paste"), this);
m_pcEditPasteAction->setToolTip(tr("Paste text from clipboard"));
m_pcEditPasteAction->setStatusTip(tr("Paste text from clipboard"));
m_pcEditPasteAction->setShortcut(QKeySequence::Paste);
connect(m_pcEditPasteAction, SIGNAL(triggered()),
m_pcCodeEditor, SLOT(paste()));
// QIcon cEditFindIcon;
// cEditFindIcon.addPixmap(QPixmap(m_pcMainWindow->GetIconDir() + "/find.png"));
// m_pcEditFindAction = new QAction(cEditFindIcon, tr("&Find/Replace"), this);
// m_pcEditFindAction->setToolTip(tr("Find/replace text"));
// m_pcEditFindAction->setStatusTip(tr("Find/replace text"));
// m_pcEditFindAction->setShortcut(QKeySequence::Find);
// connect(m_pcEditFindAction, SIGNAL(triggered()),
// this, SLOT(Find()));
QMenu* pcMenu = menuBar()->addMenu(tr("&Edit"));
pcMenu->addAction(m_pcEditUndoAction);
pcMenu->addAction(m_pcEditRedoAction);
pcMenu->addSeparator();
pcMenu->addAction(m_pcEditCopyAction);
pcMenu->addAction(m_pcEditCutAction);
pcMenu->addAction(m_pcEditPasteAction);
// pcMenu->addSeparator();
// pcMenu->addAction(m_pcEditFindAction);
QToolBar* pcToolBar = addToolBar(tr("Edit"));
pcToolBar->setObjectName("EditToolBar");
pcToolBar->setIconSize(QSize(32,32));
pcToolBar->addAction(m_pcEditUndoAction);
pcToolBar->addAction(m_pcEditRedoAction);
pcToolBar->addSeparator();
pcToolBar->addAction(m_pcEditCopyAction);
pcToolBar->addAction(m_pcEditCutAction);
pcToolBar->addAction(m_pcEditPasteAction);
// pcToolBar->addAction(m_pcEditFindAction);
}
示例14: QImage
void PathologyViewer::initializeGUIComponents(unsigned int level) {
// Initialize the minimap
std::vector<unsigned long long> overviewDimensions = _img->getLevelDimensions(level);
unsigned int size = overviewDimensions[0] * overviewDimensions[1] * _img->getSamplesPerPixel();
unsigned char* overview = new unsigned char[size];
_img->getRawRegion<unsigned char>(0, 0, overviewDimensions[0], overviewDimensions[1], level, overview);
QImage ovImg;
if (_img->getColorType() == pathology::ARGB) {
ovImg = QImage(overview, overviewDimensions[0], overviewDimensions[1], overviewDimensions[0] * 4, QImage::Format_ARGB32).convertToFormat(QImage::Format_RGB888);
}
else if (_img->getColorType() == pathology::RGB) {
ovImg = QImage(overview, overviewDimensions[0], overviewDimensions[1], overviewDimensions[0] * 3, QImage::Format_RGB888);
}
QPixmap ovPixMap = QPixmap(QPixmap::fromImage(ovImg));
delete[] overview;
if (_map) {
_map->deleteLater();
_map = NULL;
}
_map = new MiniMap(ovPixMap, this);
if (_scaleBar) {
_scaleBar->deleteLater();
_scaleBar = NULL;
}
std::vector<double> spacing = _img->getSpacing();
if (!spacing.empty()) {
_scaleBar = new ScaleBar(spacing[0], this);
}
else {
_scaleBar = new ScaleBar(-1, this);
}
if (this->layout()) {
delete this->layout();
}
QHBoxLayout * Hlayout = new QHBoxLayout(this);
QVBoxLayout * Vlayout = new QVBoxLayout();
QVBoxLayout * Vlayout2 = new QVBoxLayout();
Vlayout2->addStretch(4);
Hlayout->addLayout(Vlayout2);
Hlayout->addStretch(4);
Hlayout->setContentsMargins(30, 30, 30, 30);
Hlayout->addLayout(Vlayout, 1);
Vlayout->addStretch(4);
if (_map) {
Vlayout->addWidget(_map, 1);
}
if (_scaleBar) {
Vlayout2->addWidget(_scaleBar);
}
_map->setTileManager(_manager);
QObject::connect(this, SIGNAL(updateBBox(const QRectF&)), _map, SLOT(updateFieldOfView(const QRectF&)));
QObject::connect(_manager, SIGNAL(coverageUpdated()), _map, SLOT(onCoverageUpdated()));
QObject::connect(_map, SIGNAL(positionClicked(QPointF)), this, SLOT(moveTo(const QPointF&)));
QObject::connect(this, SIGNAL(fieldOfViewChanged(const QRectF&, const unsigned int)), _scaleBar, SLOT(updateForFieldOfView(const QRectF&)));
if (this->window()) {
_settings->beginGroup("ASAP");
QMenu* viewMenu = this->window()->findChild<QMenu*>("menuView");
if (viewMenu) {
QList<QAction*> actions = viewMenu->actions();
for (QList<QAction*>::iterator it = actions.begin(); it != actions.end(); ++it) {
if ((*it)->text() == "Toggle scale bar" && _scaleBar) {
QObject::connect((*it), SIGNAL(toggled(bool)), _scaleBar, SLOT(setVisible(bool)));
bool showComponent = _settings->value("scaleBarToggled", true).toBool();
(*it)->setChecked(showComponent);
_scaleBar->setVisible(showComponent);
}
else if ((*it)->text() == "Toggle mini-map" && _map) {
QObject::connect((*it), SIGNAL(toggled(bool)), _map, SLOT(setVisible(bool)));
bool showComponent = _settings->value("miniMapToggled", true).toBool();
(*it)->setChecked(showComponent);
_map->setVisible(showComponent);
}
示例15: QgsOptionsDialogBase
QgsVectorLayerProperties::QgsVectorLayerProperties(
QgsVectorLayer *lyr,
QWidget * parent,
Qt::WindowFlags fl
)
: QgsOptionsDialogBase( "VectorLayerProperties", parent, fl )
, layer( lyr )
, mMetadataFilled( false )
, mOriginalSubsetSQL( lyr->subsetString() )
, mSaveAsMenu( nullptr )
, mLoadStyleMenu( nullptr )
, mRendererDialog( nullptr )
, labelingDialog( nullptr )
, labelDialog( nullptr )
, actionDialog( nullptr )
, diagramPropertiesDialog( nullptr )
, mFieldsPropertiesDialog( nullptr )
{
setupUi( this );
// QgsOptionsDialogBase handles saving/restoring of geometry, splitter and current tab states,
// switching vertical tabs between icon/text to icon-only modes (splitter collapsed to left),
// and connecting QDialogButtonBox's accepted/rejected signals to dialog's accept/reject slots
initOptionsBase( false );
QPushButton* b = new QPushButton( tr( "Style" ) );
QMenu* m = new QMenu( this );
mActionLoadStyle = m->addAction( tr( "Load Style" ), this, SLOT( loadStyle_clicked() ) );
mActionSaveStyleAs = m->addAction( tr( "Save Style" ), this, SLOT( saveStyleAs_clicked() ) );
m->addSeparator();
m->addAction( tr( "Save as Default" ), this, SLOT( saveDefaultStyle_clicked() ) );
m->addAction( tr( "Restore Default" ), this, SLOT( loadDefaultStyle_clicked() ) );
b->setMenu( m );
connect( m, SIGNAL( aboutToShow() ), this, SLOT( aboutToShowStyleMenu() ) );
buttonBox->addButton( b, QDialogButtonBox::ResetRole );
connect( lyr->styleManager(), SIGNAL( currentStyleChanged( QString ) ), this, SLOT( syncToLayer() ) );
connect( buttonBox->button( QDialogButtonBox::Apply ), SIGNAL( clicked() ), this, SLOT( apply() ) );
connect( this, SIGNAL( accepted() ), this, SLOT( apply() ) );
connect( this, SIGNAL( rejected() ), this, SLOT( onCancel() ) );
connect( mOptionsStackedWidget, SIGNAL( currentChanged( int ) ), this, SLOT( mOptionsStackedWidget_CurrentChanged( int ) ) );
fieldComboBox->setLayer( lyr );
displayFieldComboBox->setLayer( lyr );
connect( insertFieldButton, SIGNAL( clicked() ), this, SLOT( insertField() ) );
connect( insertExpressionButton, SIGNAL( clicked() ), this, SLOT( insertExpression() ) );
// connections for Map Tip display
connect( htmlRadio, SIGNAL( toggled( bool ) ), htmlMapTip, SLOT( setEnabled( bool ) ) );
connect( htmlRadio, SIGNAL( toggled( bool ) ), insertFieldButton, SLOT( setEnabled( bool ) ) );
connect( htmlRadio, SIGNAL( toggled( bool ) ), fieldComboBox, SLOT( setEnabled( bool ) ) );
connect( htmlRadio, SIGNAL( toggled( bool ) ), insertExpressionButton, SLOT( setEnabled( bool ) ) );
connect( fieldComboRadio, SIGNAL( toggled( bool ) ), displayFieldComboBox, SLOT( setEnabled( bool ) ) );
if ( !layer )
return;
QVBoxLayout *layout;
if ( layer->hasGeometryType() )
{
// Create the Labeling dialog tab
layout = new QVBoxLayout( labelingFrame );
layout->setMargin( 0 );
labelingDialog = new QgsLabelingWidget( layer, QgisApp::instance()->mapCanvas(), labelingFrame );
labelingDialog->layout()->setContentsMargins( -1, 0, -1, 0 );
layout->addWidget( labelingDialog );
labelingFrame->setLayout( layout );
// Create the Labeling (deprecated) dialog tab
layout = new QVBoxLayout( labelOptionsFrame );
layout->setMargin( 0 );
labelDialog = new QgsLabelDialog( layer->label(), labelOptionsFrame );
labelDialog->layout()->setMargin( 0 );
layout->addWidget( labelDialog );
labelOptionsFrame->setLayout( layout );
connect( labelDialog, SIGNAL( labelSourceSet() ), this, SLOT( setLabelCheckBox() ) );
}
else
{
labelingDialog = nullptr;
labelDialog = nullptr;
mOptsPage_Labels->setEnabled( false ); // disable labeling item
mOptsPage_LabelsOld->setEnabled( false ); // disable labeling (deprecated) item
}
// Create the Actions dialog tab
QVBoxLayout *actionLayout = new QVBoxLayout( actionOptionsFrame );
actionLayout->setMargin( 0 );
const QgsFields &fields = layer->fields();
actionDialog = new QgsAttributeActionDialog( layer->actions(), fields, actionOptionsFrame );
actionDialog->layout()->setMargin( 0 );
actionLayout->addWidget( actionDialog );
// Create the menu for the save style button to choose the output format
mSaveAsMenu = new QMenu( this );
mSaveAsMenu->addAction( tr( "QGIS Layer Style File..." ) );
mSaveAsMenu->addAction( tr( "SLD File..." ) );
//.........这里部分代码省略.........