本文整理汇总了C++中QMenu::sizeHint方法的典型用法代码示例。如果您正苦于以下问题:C++ QMenu::sizeHint方法的具体用法?C++ QMenu::sizeHint怎么用?C++ QMenu::sizeHint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMenu
的用法示例。
在下文中一共展示了QMenu::sizeHint方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: showOptions
void XYFitCurveDock::showOptions() {
QMenu menu;
FitOptionsWidget w(&menu, &m_fitData);
connect(&w, SIGNAL(finished()), &menu, SLOT(close()));
connect(&w, SIGNAL(optionsChanged()), this, SLOT(enableRecalculate()));
QWidgetAction* widgetAction = new QWidgetAction(this);
widgetAction->setDefaultWidget(&w);
menu.addAction(widgetAction);
QPoint pos(-menu.sizeHint().width()+uiGeneralTab.pbParameters->width(),-menu.sizeHint().height());
menu.exec(uiGeneralTab.pbOptions->mapToGlobal(pos));
}
示例2: showFunctions
void XYFitCurveDock::showFunctions() {
QMenu menu;
FunctionsWidget functions(&menu);
connect(&functions, SIGNAL(functionSelected(QString)), this, SLOT(insertFunction(QString)));
connect(&functions, SIGNAL(functionSelected(QString)), &menu, SLOT(close()));
QWidgetAction* widgetAction = new QWidgetAction(this);
widgetAction->setDefaultWidget(&functions);
menu.addAction(widgetAction);
QPoint pos(-menu.sizeHint().width()+uiGeneralTab.tbFunctions->width(),-menu.sizeHint().height());
menu.exec(uiGeneralTab.tbFunctions->mapToGlobal(pos));
}
示例3: showConstants
void MatrixFunctionDialog::showConstants() {
QMenu menu;
ConstantsWidget constants(&menu);
connect(&constants, SIGNAL(constantSelected(QString)), this, SLOT(insertConstant(QString)));
connect(&constants, SIGNAL(constantSelected(QString)), &menu, SLOT(close()));
connect(&constants, SIGNAL(canceled()), &menu, SLOT(close()));
QWidgetAction* widgetAction = new QWidgetAction(this);
widgetAction->setDefaultWidget(&constants);
menu.addAction(widgetAction);
QPoint pos(-menu.sizeHint().width()+ui.tbConstants->width(),-menu.sizeHint().height());
menu.exec(ui.tbConstants->mapToGlobal(pos));
}
示例4: showMenu
void ToolButton::showMenu()
{
if (!m_showMenuInside) {
QToolButton::showMenu();
return;
}
QMenu* m = menu();
if (!m) {
return;
}
emit aboutToShowMenu();
QPoint pos = mapToGlobal(rect().bottomRight());
if (QApplication::layoutDirection() == Qt::RightToLeft) {
pos.setX(pos.x() - rect().width());
}
else {
pos.setX(pos.x() - m->sizeHint().width());
}
m->popup(pos);
}
示例5: QVERIFY
void tst_QMenu::task242454_sizeHint()
{
QMenu menu;
QString s = QLatin1String("foo\nfoo\nfoo\nfoo");
menu.addAction(s);
QVERIFY(menu.sizeHint().width() > menu.fontMetrics().boundingRect(QRect(), Qt::TextSingleLine, s).width());
}
示例6: buttonClicked
bool AnimatedVectorControl::buttonClicked(unsigned int index)
{
bool isAnimated = m_pairedValue->isAnimated();
QMenu* m = new QMenu(m_pAnimationButton);
if (!isAnimated)
{
m->addAction(m_actSetAnimated);
}
else
{
m->addAction(m_actDeleteAnimation);
m->addAction(m_actSetKey);
m->addAction(m_actDeleteKey);
m->addSeparator();
m->addAction(m_actLinearInterpolation);
m->addAction(m_actQuadraticInterpolation);
m->addAction(m_actCubicInterpolation);
}
QSize menuSize = m->sizeHint();
QSize buttonSize = m_pAnimationButton->geometry().size();
m->move(m_pAnimationButton->mapToGlobal(QPoint(buttonSize.width() - menuSize.width(), buttonSize.height())));
m->show();
return false;
}
示例7: showPopup
void MyQComboBox::showPopup()
{
QRect desk = popupGeometry(QApplication::desktop()->screenNumber(this));
QPoint popupPoint = mapToGlobal(QPoint(0, 0));
const int dateFrameHeight = _menu->sizeHint().height();
if (popupPoint.y() + height() + dateFrameHeight > desk.bottom()) {
popupPoint.setY(popupPoint.y() - dateFrameHeight);
} else {
popupPoint.setY(popupPoint.y() + height());
}
const int dateFrameWidth = _menu->sizeHint().width();
if (popupPoint.x() + dateFrameWidth > desk.right()) {
popupPoint.setX(desk.right() - dateFrameWidth);
}
if (popupPoint.x() < desk.left()) {
popupPoint.setX(desk.left());
}
if (popupPoint.y() < desk.top()) {
popupPoint.setY(desk.top());
}
_menu->popup(popupPoint);
}
示例8: contextMenuEvent
void LXQtTaskGroup::contextMenuEvent(QContextMenuEvent *event)
{
setPopupVisible(false, true);
mPreventPopup = true;
if (windowId())
{
LXQtTaskButton::contextMenuEvent(event);
return;
}
QMenu * menu = new QMenu(tr("Group"));
menu->setAttribute(Qt::WA_DeleteOnClose);
QAction *a = menu->addAction(XdgIcon::fromTheme("process-stop"), tr("Close group"));
connect(a, SIGNAL(triggered()), this, SLOT(closeGroup()));
connect(menu, &QMenu::aboutToHide, [this] {
mPreventPopup = false;
});
menu->setGeometry(mPlugin->panel()->calculatePopupWindowPos(mapToGlobal(event->pos()), menu->sizeHint()));
mPlugin->willShowWindow(menu);
menu->show();
}
示例9: showOptionsMenu
void FullScreenContent::showOptionsMenu()
{
Q_ASSERT(!mConfigWidget);
mConfigWidget = new FullScreenConfigWidget;
FullScreenConfigWidget* widget = mConfigWidget;
// Put widget in a menu
QMenu menu;
QWidgetAction* action = new QWidgetAction(&menu);
action->setDefaultWidget(widget);
menu.addAction(action);
// Slideshow checkboxes
widget->mSlideShowLoopCheckBox->setChecked(mSlideShow->loopAction()->isChecked());
connect(widget->mSlideShowLoopCheckBox, SIGNAL(toggled(bool)),
mSlideShow->loopAction(), SLOT(trigger()));
widget->mSlideShowRandomCheckBox->setChecked(mSlideShow->randomAction()->isChecked());
connect(widget->mSlideShowRandomCheckBox, SIGNAL(toggled(bool)),
mSlideShow->randomAction(), SLOT(trigger()));
// Interval slider
widget->mSlideShowIntervalSlider->setValue(int(GwenviewConfig::interval()));
connect(widget->mSlideShowIntervalSlider, SIGNAL(valueChanged(int)),
mSlideShow, SLOT(setInterval(int)));
connect(widget->mSlideShowIntervalSlider, SIGNAL(valueChanged(int)),
SLOT(updateSlideShowIntervalLabel()));
// Interval label
QString text = formatSlideShowIntervalText(88);
int width = widget->mSlideShowIntervalLabel->fontMetrics().width(text);
widget->mSlideShowIntervalLabel->setFixedWidth(width);
updateSlideShowIntervalLabel();
// Image information
connect(widget->mConfigureDisplayedInformationButton, SIGNAL(clicked()),
SLOT(showImageMetaInfoDialog()));
// Thumbnails
widget->mThumbnailGroupBox->setVisible(mViewPageVisible);
if (mViewPageVisible) {
widget->mShowThumbnailsCheckBox->setChecked(GwenviewConfig::showFullScreenThumbnails());
widget->mHeightSlider->setMinimum(mRightToolBar->sizeHint().height());
widget->mHeightSlider->setValue(mThumbnailBar->height());
connect(widget->mShowThumbnailsCheckBox, SIGNAL(toggled(bool)),
SLOT(slotShowThumbnailsToggled(bool)));
connect(widget->mHeightSlider, SIGNAL(valueChanged(int)),
SLOT(setFullScreenBarHeight(int)));
}
// Show menu below its button
QPoint pos;
QWidget* button = mOptionsAction->associatedWidgets().first();
Q_ASSERT(button);
qWarning() << button << button->geometry();
if (QApplication::isRightToLeft()) {
pos = button->mapToGlobal(button->rect().bottomLeft());
} else {
pos = button->mapToGlobal(button->rect().bottomRight());
pos.rx() -= menu.sizeHint().width();
}
qWarning() << pos;
menu.exec(pos);
}