本文整理汇总了C++中QWidgetAction::setDefaultWidget方法的典型用法代码示例。如果您正苦于以下问题:C++ QWidgetAction::setDefaultWidget方法的具体用法?C++ QWidgetAction::setDefaultWidget怎么用?C++ QWidgetAction::setDefaultWidget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWidgetAction
的用法示例。
在下文中一共展示了QWidgetAction::setDefaultWidget方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setting
CDTMapToolSelectTrainingSamples::CDTMapToolSelectTrainingSamples(QgsMapCanvas *canvas) :
QgsMapTool(canvas),
mapCanvas(canvas),
toolBar(new CDTCategoryToolBar(tr("Select training samples"),MainWindow::getMainWindow())),
model(new QSqlQueryModel(this))
{
toolBar->setFloatable(true);
toolBar->setMovable(true);
toolBar->show();
toolBar->raise();
QSettings setting("WHU","CDTStudio");
setting.beginGroup("CDTCategoryToolBar");
QByteArray geometry = setting.value("Geometry").toByteArray();
setting.endGroup();
if (geometry.isEmpty())
{
QPoint ptGlobal = MainWindow::getCurrentMapCanvas()->mapToGlobal(MainWindow::getCurrentMapCanvas()->rect().center());
toolBar->move(MainWindow::getMainWindow()->mapFromGlobal(ptGlobal));
}
else
toolBar->restoreGeometry(geometry);
comboBoxCategory = new QComboBox(toolBar);
comboBoxCategory->setModel(model);
QWidgetAction *actionLabel = new QWidgetAction(this);
QWidgetAction *actionCombo = new QWidgetAction(this);
actionLabel->setDefaultWidget(new QLabel(tr("Category"),toolBar));
actionCombo->setDefaultWidget(comboBoxCategory);
toolBar->addAction(actionLabel);
toolBar->addAction(actionCombo);
MainWindow::getMainWindow()->addToolBar(toolBar);
}
示例2: showToolBarStylePopupMenu
void PdfViewer::showToolBarStylePopupMenu(const QPoint &pos)
{
QMenu *popupMenu = new QMenu(this);
popupMenu->setAttribute(Qt::WA_DeleteOnClose);
popupMenu->move(mapToGlobal(QPoint(0,0)) + pos);
QWidgetAction *iconOnlyAction = new QWidgetAction(popupMenu);
QRadioButton *iconOnlyRadio = new QRadioButton(tr("&Icons Only"), popupMenu);
iconOnlyAction->setDefaultWidget(iconOnlyRadio);
QWidgetAction *textOnlyAction = new QWidgetAction(popupMenu);
QRadioButton *textOnlyRadio = new QRadioButton(tr("&Text Only"), popupMenu);
textOnlyAction->setDefaultWidget(textOnlyRadio);
QWidgetAction *textBesideIconAction = new QWidgetAction(popupMenu);
QRadioButton *textBesideIconRadio = new QRadioButton(tr("Text &Alongside Icons"), popupMenu);
textBesideIconAction->setDefaultWidget(textBesideIconRadio);
QWidgetAction *textUnderIconAction = new QWidgetAction(popupMenu);
QRadioButton *textUnderIconRadio = new QRadioButton(tr("Text &Under Icons"), popupMenu);
textUnderIconAction->setDefaultWidget(textUnderIconRadio);
QButtonGroup *popupButtonGroup = new QButtonGroup(popupMenu);
popupButtonGroup->addButton(iconOnlyRadio);
popupButtonGroup->addButton(textOnlyRadio);
popupButtonGroup->addButton(textBesideIconRadio);
popupButtonGroup->addButton(textUnderIconRadio);
popupButtonGroup->setId(iconOnlyRadio, 0);
popupButtonGroup->setId(textOnlyRadio, 1);
popupButtonGroup->setId(textBesideIconRadio, 2);
popupButtonGroup->setId(textUnderIconRadio, 3);
connect(popupButtonGroup, SIGNAL(buttonClicked(int)), this, SLOT(slotChangeToolBarStyle(int)));
popupMenu->addAction(iconOnlyAction);
popupMenu->addAction(textOnlyAction);
popupMenu->addAction(textBesideIconAction);
popupMenu->addAction(textUnderIconAction);
popupMenu->setContentsMargins(5, 0, 5, 0);
QSettings settings;
settings.beginGroup("MainWindow");
const int toolBarStyleNumber = settings.value("ToolBarStyle", 0).toInt();
switch (toolBarStyleNumber)
{
case 0: iconOnlyRadio->setChecked(true); break;
case 1: textOnlyRadio->setChecked(true); break;
case 2: textBesideIconRadio->setChecked(true); break;
case 3: textUnderIconRadio->setChecked(true); break;
}
settings.endGroup();
popupMenu->show();
// make sure that the popupMenu stays completely inside the screen (must be done after popupMenu->show() in order to have the correct width)
const int desktopWidth = QApplication::desktop()->availableGeometry(this).width();
if (popupMenu->x() + popupMenu->width() > desktopWidth)
popupMenu->move(desktopWidth - popupMenu->width(), popupMenu->y());
}
示例3: QMainWindow
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
QString strNumber = "k";
int nNumber = strNumber.toInt( );
strNumber = "";
nNumber = strNumber.toInt( );
QString strDateTime = "2011-01-06 01:02:03";
QString strFormat = "yyyy-M-d H:m:s";
QDateTime dt = QDateTime::fromString( strDateTime, strFormat );
strDateTime = "";
strDateTime = dt.toString( "yyyy-MM-dd HH:mm:ss" );
ui->setupUi(this);
//QPalette pal;
//QPixmap map( "D:/WinParkUI/debug/Image/NewIcon/CommonBG-normal.jpg");
//QBrush br( map );
//pal.setBrush( backgroundRole( ), br );
//setPalette( pal );
//setAutoFillBackground( true );
//mysql.DbConnect( "192.168.1.51", "test", "test", "parkadmin", 3306 );
//QSplitter *splitter = new QSplitter(this);
//splitter->setGeometry( this->geometry( ) );
//splitter->addWidget( ui->pushButton );
//splitter->addWidget( ui->tableWidget );
//splitter->addWidget( ui->pushButton_3 );
QWidgetAction* act = new QWidgetAction( ui->menuTest );
QComboBox* cbx = new QComboBox( ui->menuTest );
QStringList lst;
lst << "1" << "2" << "3";
cbx->addItems( lst );
act->setDefaultWidget( cbx );
//ui->toolBar->addAction( act );
act->setText( "Hello" );
ui->menuTest->addAction( act );
act = new QWidgetAction( ui->menuTest );
QDateTimeEdit* edit = new QDateTimeEdit( ui->menuTest );
edit->setCalendarPopup( true );
act->setDefaultWidget( edit );
ui->menuTest->addAction( act );
}
示例4: initBrushMenu
void CMainWindow::initBrushMenu()
{
// allocate menu members
brushMenuAction = new QAction(drawDefActions);
brushMenu = new QMenu(this);
QWidgetAction *brushSelectorWidgetAction = new QWidgetAction(this);
CBrushSelector *brushSelector = new CBrushSelector(brushMenu);
// misc
brushSelectorWidgetAction->setDefaultWidget(brushSelector);
brushMenu->addAction(brushSelectorWidgetAction);
brushMenuAction->setToolTip(tr("Brush"));
brushMenuAction->setIcon(QIcon(":/images/brush.png"));
brushMenuAction->setMenu(brushMenu);
drawDefBar->addAction(brushMenuAction);
// make connections to main window
connect(brushMenuAction, SIGNAL(triggered(bool)),
this, SLOT(brushActionTriggeredSlot(bool)));
connect(brushSelector, SIGNAL(closeSignal()),
this, SLOT(closeBrushMenu()));
//connect(brushSelector, SIGNAL(sendBrushSettings(const CBrushSettings *)),
// this, SLOT(receiveBrushSettings(const CBrushSettings *)));
}
示例5: initPenMenu
void CMainWindow::initPenMenu()
{
// allocate menu members
penMenuAction = new QAction(drawDefActions);
penMenu = new QMenu(this);
QWidgetAction *penSelectorWidgetAction = new QWidgetAction(this);
CPenSelector *penSelector = new CPenSelector(penMenu);
// misc
penMenuAction->setToolTip(tr("Pen"));
penMenuAction->setShortcut(tr("Ctrl+E"));
penMenuAction->setIcon(QIcon(":/images/pen2.png"));
penMenuAction->setMenu(penMenu);
drawDefBar->addAction(penMenuAction);
penSelectorWidgetAction->setDefaultWidget(penSelector);
penMenu->addAction(penSelectorWidgetAction);
// make connections to main window
//connect(penSelector , SIGNAL(penUpdateSig(QPen &)),
// this , SLOT(receivePen(QPen &)));
connect(penSelector, SIGNAL(sendPenSettings(const CPenSettings *)),
this, SLOT(receivePenSettings(const CPenSettings *)));
connect(penSelector, SIGNAL(closeSignal()),
this, SLOT(closePenMenu()));
connect(penMenuAction, SIGNAL(triggered(bool)),
this, SLOT(penActionTriggeredSlot(bool)));
// request default settings
//emit updatePenSig(penSelector->getPen());
}
示例6: contextMenu
QMenu* Scene_polylines_item::contextMenu()
{
const char* prop_name = "Menu modified by Scene_polylines_item.";
QMenu* menu = Scene_item::contextMenu();
// Use dynamic properties:
// http://doc.qt.io/qt-5/qobject.html#property
bool menuChanged = menu->property(prop_name).toBool();
if(!menuChanged) {
menu->addSeparator();
// TODO: add actions to display corners
QAction* action = menu->addAction(tr("Display corners with radius..."));
connect(action, SIGNAL(triggered()),
this, SLOT(change_corner_radii()));
QAction* actionSmoothPolylines =
menu->addAction(tr("Smooth polylines"));
actionSmoothPolylines->setObjectName("actionSmoothPolylines");
connect(actionSmoothPolylines, SIGNAL(triggered()),this, SLOT(smooth()));
QMenu *container = new QMenu(tr("Line Width"));
QWidgetAction *sliderAction = new QWidgetAction(0);
connect(d->line_Slider, &QSlider::valueChanged, this, &Scene_polylines_item::itemChanged);
sliderAction->setDefaultWidget(d->line_Slider);
container->addAction(sliderAction);
menu->addMenu(container);
menu->setProperty(prop_name, true);
}
return menu;
}
示例7: QMenu
EmoticonMenu::EmoticonMenu(QWidget *parent) :
QMenu(parent)
{
layout = new QGridLayout(this);
layout->setContentsMargins(1,1,1,1);
layout->setSpacing(0);
QWidgetAction *action = new QWidgetAction(this);
action->setDefaultWidget(new QWidget(this));
action->defaultWidget()->setLayout(layout);
this->addAction(action);
// some Skype smileys
addEmoticon(":/icons/emoticons/emotion_smile.png", {":)", ":-)", ":o)"});
addEmoticon(":/icons/emoticons/emotion_sad.png", {":(", ":-("});
addEmoticon(":/icons/emoticons/emotion_grin.png", {":D", ":-D"});
addEmoticon(":/icons/emoticons/emotion_cool.png", {"8)", "8-)"});
addEmoticon(":/icons/emoticons/emotion_suprised.png", {":O", ":-O"});
addEmoticon(":/icons/emoticons/emotion_wink.png", {";)", ";-)"});
addEmoticon(":/icons/emoticons/emotion_cry.png", {";(", ";-("});
addEmoticon(":/icons/emoticons/emotion_sweat.png", {"(:|"});
// ...
addEmoticon(":/icons/emoticons/emotion_kiss.png", {":*", ":-*"});
addEmoticon(":/icons/emoticons/emotion_tongue.png", {":P", ":-P"});
// ...
addEmoticon(":/icons/emoticons/emotion_doubt.png", {":^)", ":^-)"});
// ...
addEmoticon(":/icons/emoticons/emotion_love.png", {"(inlove)"});
addEmoticon(":/icons/emoticons/emotion_evilgrin.png", {"]:)", "]:-)"});
// ...
addEmoticon(":/icons/emoticons/emotion_angel.png", {"O:)", "O:-)", "o:)", "o:-)", "(angel)"});
// ...
}
示例8: initShapeMenu
void CMainWindow::initShapeMenu()
{
shapeMenuAction = new QAction(drawDefActions);
shapeMenuAction->setToolTip(tr("Shapes"));
connect(shapeMenuAction, SIGNAL(triggered(bool)), this, SLOT(shapeActionTriggeredSlot(bool)));
shapeMenu = new QMenu(this);
shapeMenuAction->setIcon(QIcon(":/images/shapes.png"));
QWidgetAction *shapeSelectorWidgetAction = new QWidgetAction(this);
CShapeSelector *shapeSelector = new CShapeSelector(shapeMenu);
shapeSelectorWidgetAction->setDefaultWidget(shapeSelector);
shapeMenu->addAction(shapeSelectorWidgetAction);
connect(shapeSelector, SIGNAL(shapeChangeSig(shapeType)),
this, SLOT(receiveShape(shapeType)));
connect(shapeSelector, SIGNAL(xRadChangeSig(int)),
this, SLOT(receiveRadiusForRoundedRec_X(int)));
connect(shapeSelector, SIGNAL(yRadChangeSig(int)),
this, SLOT(receiveRadiusForRoundedRec_Y(int)));
connect(shapeSelector, SIGNAL(doCloseShapeMenuSig()),
this, SLOT(closeShapeMenu()));
shapeMenuAction->setMenu(shapeMenu);
drawDefBar->addAction(shapeMenuAction);
}
示例9: QToolButton
VolumeButton::VolumeButton(QWidget *parent) :
QToolButton(parent), menu(0), label(0), slider(0)
{
setIcon(style()->standardIcon(QStyle::SP_MediaVolume));
setPopupMode(QToolButton::InstantPopup);
QWidget *popup = new QWidget(this);
slider = new QSlider(Qt::Horizontal, popup);
slider->setRange(0, 100);
connect(slider, SIGNAL(valueChanged(int)), this, SIGNAL(volumeChanged(int)));
label = new QLabel(popup);
label->setAlignment(Qt::AlignCenter);
label->setNum(100);
label->setMinimumWidth(label->sizeHint().width());
connect(slider, SIGNAL(valueChanged(int)), label, SLOT(setNum(int)));
QBoxLayout *popupLayout = new QHBoxLayout(popup);
popupLayout->setMargin(2);
popupLayout->addWidget(slider);
popupLayout->addWidget(label);
QWidgetAction *action = new QWidgetAction(this);
action->setDefaultWidget(popup);
menu = new QMenu(this);
menu->addAction(action);
setMenu(menu);
stylize();
}
示例10: KPushButton
KisMouseInputEditor::KisMouseInputEditor(QWidget *parent)
: KPushButton(parent), d(new Private)
{
QWidget *popup = new QWidget();
d->ui = new Ui::KisMouseInputEditor;
d->ui->setupUi(popup);
d->ui->mouseButton->setType(KisInputButton::MouseType);
d->ui->clearModifiersButton->setIcon(KisIconUtils::loadIcon("edit-clear"));
d->ui->clearMouseButton->setIcon(KisIconUtils::loadIcon("edit-clear"));
QWidgetAction *action = new QWidgetAction(this);
action->setDefaultWidget(popup);
QMenu *menu = new QMenu(this);
menu->addAction(action);
setMenu(menu);
QTimer::singleShot(0, this, SLOT(showMenu()));
connect(d->ui->mouseButton, SIGNAL(dataChanged()), SLOT(updateLabel()));
connect(d->ui->modifiersButton, SIGNAL(dataChanged()), SLOT(updateLabel()));
connect(d->ui->clearMouseButton, SIGNAL(clicked(bool)), d->ui->mouseButton, SLOT(clear()));
connect(d->ui->clearModifiersButton, SIGNAL(clicked(bool)), d->ui->modifiersButton, SLOT(clear()));
}
示例11: addOption
void ComponentWidget::addOption(QWidget *widget)
{
QWidgetAction *action = new QWidgetAction(widget);
action->setDefaultWidget(widget);
m_componentUi.optionsButton->menu()->addAction(action);
}
示例12: QMenu
NBCategoryMenu::NBCategoryMenu( QString catName, QPixmap icon, QString wNode, QModelIndexList nodeList, QWidget *parent ) : QMenu( parent ) {
mCategory = catName;
mWorkNode = wNode;
sNodes << nodeList;
QWidgetAction *title = new QWidgetAction( this );
QWidget *actBase = new QWidget( this );
QLabel *pix = new QLabel();
pix->setFixedSize( 20, 20 );
pix->setPixmap( icon.scaled( 16, 16, Qt::KeepAspectRatio, Qt::SmoothTransformation ) );
pix->setAlignment( Qt::AlignCenter );
QLabel *name = new QLabel( "<b>" + catName + "</b>" );
name->setFixedHeight( 20 );
name->setAlignment( Qt::AlignVCenter );
QHBoxLayout *lyt = new QHBoxLayout();
lyt->setContentsMargins( QMargins( 4, 4, 4, 0 ) );
lyt->addWidget( pix );
lyt->addWidget( name );
actBase->setLayout( lyt );
title->setDefaultWidget( actBase );
addAction( title );
addSeparator();
populateMenu();
};
示例13: contextPopupAboutToShow
void KviStatusBar::contextPopupAboutToShow()
{
if(!m_pContextPopup)
return;
m_pContextPopup->clear();
if(appletExists(m_pClickedApplet))
{
QString szApp = m_pClickedApplet->descriptor()->visibleName();
QString szTmp = QString("<center><b>%1</b></center>").arg(szApp);
QLabel * pLabel = new QLabel(szTmp,m_pContextPopup);
QPalette p;
pLabel->setStyleSheet("background-color: " + p.color(QPalette::Normal, QPalette::Mid).name());
QWidgetAction * pWaction = new QWidgetAction(m_pContextPopup);
pWaction->setDefaultWidget(pLabel);
m_pContextPopup->addAction(pWaction);
m_pClickedApplet->fillContextPopup(m_pContextPopup);
szTmp = QString(__tr2qs("Remove %1")).arg(szApp);
m_pContextPopup->addSeparator();
m_pContextPopup->addAction(szTmp,this,SLOT(removeClickedApplet()));
}
if(!m_pAppletsPopup)
{
m_pAppletsPopup = new QMenu(this);
connect(m_pAppletsPopup,SIGNAL(aboutToShow()),this,SLOT(appletsPopupAboutToShow()));
connect(m_pAppletsPopup,SIGNAL(triggered(QAction *)),this,SLOT(appletsPopupActivated(QAction *)));
}
示例14: setupContextMenu
void ComicMainWindow::setupContextMenu()
{
QMenu *cmenu = view->contextMenu();
pageinfo = new QLabel(cmenu);
pageinfo->setMargin(3);
pageinfo->setAlignment(Qt::AlignHCenter);
pageinfo->setFrameStyle(QFrame::Box | QFrame::Raised);
QWidgetAction *actionPageInfo = new QWidgetAction(this);
actionPageInfo->setDefaultWidget(pageinfo);
cmenu->addAction(actionNextPage);
cmenu->addAction(actionPreviousPage);
cmenu->addSeparator();
cmenu->addAction(actionFitWidth);
cmenu->addAction(actionFitHeight);
cmenu->addAction(actionWholePage);
cmenu->addAction(actionOriginalSize);
cmenu->addAction(actionBestFit);
cmenu->addSeparator();
cmenu->addAction(actionRotateRight);
cmenu->addAction(actionRotateLeft);
cmenu->addAction(actionNoRotation);
cmenu->addSeparator();
cmenu->addAction(actionTwoPages);
cmenu->addAction(actionMangaMode);
cmenu->addSeparator();
cmenu->addAction(actionFullscreen);
cmenu->addAction(actionPageInfo);
}
示例15: initSelectionMenu
void CMainWindow::initSelectionMenu()
{
selectionMenuAction = new QAction(drawDefActions);
selectionMenuAction->setToolTip(tr("Segmentation"));
connect(selectionMenuAction, SIGNAL(triggered(bool)),
this, SLOT(selectionMenuActionTriggeredSlot(bool)));
selectionMenu = new QMenu(this);
selectionMenuAction->setIcon(QIcon(":/images/shapes.png"));
QWidgetAction *selectionWidgetAction = new QWidgetAction(this);
selectionSpecifier = new CSelectionSelector(this);
selectionWidgetAction->setDefaultWidget(selectionSpecifier);
selectionMenu->addAction(selectionWidgetAction);
selectionMenuAction->setMenu(selectionMenu);
drawDefBar->addAction(selectionMenuAction);
// create toolbar and its widgets
//selectionActions = new QActionGroup(this);
//selectionToolBar = new QToolBar("Define Selection", this);
//selectionToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
//selectionToolBar->setIconSize(QSize(40,40));
//selectionToolBar->setAllowedAreas(Qt::NoToolBarArea);
//selectionSpecifier = new CSelectionSelector(this);
//selectionToolBar->addWidget(selectionSpecifier);
//addToolBar(selectionToolBar);
// connections
connect(this, SIGNAL(requestSelectionMode()),
selectionSpecifier, SLOT(resondToRequestAll()));
// NOT IMPLEMENTED :
//connect(selectionSpecifier, SIGNAL(updateSelectionActionFromWidgetSig(TSelectionAction )),
// this, SIGNAL(selectionActionFromToolbarSig(TSelectionAction)));
connect(selectionSpecifier, SIGNAL(updateSelectionModeFromWidgetSig(TSelectionMode)),
this, SIGNAL(selectionModeFromToolbarSig(TSelectionMode)));
connect(selectionSpecifier, SIGNAL(updateSelectionOptionFromWidgetSig(TSelectionOption)),
this, SIGNAL(selectionOptionFromToolbarSig(TSelectionOption)));
connect(selectionSpecifier, SIGNAL(updateCompositionMode(QPainter::CompositionMode)),
this, SIGNAL(selectionCompModeFromToolbarSig(QPainter::CompositionMode)));
connect(selectionSpecifier, SIGNAL(updateCompositionAlpha(int)),
this, SIGNAL(selectionCompAlphaFromToolbarSig(int)));
connect(selectionSpecifier, SIGNAL(updateTransformationMode(TTransformationMode)),
this, SIGNAL(selectionTransformationFromToolbarSig(TTransformationMode)));
connect(selectionSpecifier, SIGNAL(updateRotationAxis(Qt::Axis, bool)),
this, SIGNAL(selectionRotationAxisFromToolbarSig(Qt::Axis, bool)));
connect(selectionSpecifier, SIGNAL(updateTransformationSquare(bool)),
this, SIGNAL(selectionTransformationSquareFromToolbarSig(bool)));
}