本文整理汇总了C++中QAbstractButton::mapToGlobal方法的典型用法代码示例。如果您正苦于以下问题:C++ QAbstractButton::mapToGlobal方法的具体用法?C++ QAbstractButton::mapToGlobal怎么用?C++ QAbstractButton::mapToGlobal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAbstractButton
的用法示例。
在下文中一共展示了QAbstractButton::mapToGlobal方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ask
void MigrateDialog::ask()
{
QAbstractButton *btn = button( QWizard::CancelButton );
QPoint p = btn->mapToGlobal(QPoint(0, 0));
QRect rc(p.x(), p.y(), btn->width(), btn->height());
BalloonMsg::ask(NULL, i18n("Cancel convert?"), this, SLOT(cancel(void*)), NULL, &rc);
}
示例2: onMenu
void BleMainWindow::onMenu()
{
QMenu menu(this);
menu.addAction(tr("&Quit"), this, SLOT(onClose()));
menu.addAction(tr("&Settings"), this, SLOT(onSettins()));
QAbstractButton *menuButton = ui->titleWidget->button(TitleWidget::MENU_HINT);
menu.exec(menuButton->mapToGlobal(menu.rect().bottomLeft()));
}
示例3: onDataSourceButtonRightClicked
void AMScanViewScanBar::onDataSourceButtonRightClicked(const QPoint& location) {
QAbstractButton* button = qobject_cast<QAbstractButton*>(sender());
if(!button)
return;
int dataSourceIndex = sourceButtons_.id(button);
AMScanViewScanBarContextMenu* cm = new AMScanViewScanBarContextMenu(model_, scanIndex_, dataSourceIndex, button);
cm->popup(button->mapToGlobal(location));
}
示例4: moveFocus
void QAbstractButtonPrivate::moveFocus(int key)
{
QList<QAbstractButton *> buttonList = queryButtonList();;
#ifndef QT_NO_BUTTONGROUP
bool exclusive = group ? group->d_func()->exclusive : autoExclusive;
#else
bool exclusive = autoExclusive;
#endif
QWidget *f = QApplication::focusWidget();
QAbstractButton *fb = qobject_cast<QAbstractButton *>(f);
if (!fb || !buttonList.contains(fb))
return;
QAbstractButton *candidate = 0;
int bestScore = -1;
QRect target = f->rect().translated(f->mapToGlobal(QPoint(0,0)));
QPoint goal = target.center();
uint focus_flag = qt_tab_all_widgets ? Qt::TabFocus : Qt::StrongFocus;
for (int i = 0; i < buttonList.count(); ++i) {
QAbstractButton *button = buttonList.at(i);
if (button != f && button->window() == f->window() && button->isEnabled() && !button->isHidden() &&
(autoExclusive || (button->focusPolicy() & focus_flag) == focus_flag)) {
QRect buttonRect = button->rect().translated(button->mapToGlobal(QPoint(0,0)));
QPoint p = buttonRect.center();
//Priority to widgets that overlap on the same coordinate.
//In that case, the distance in the direction will be used as significant score,
//take also in account orthogonal distance in case two widget are in the same distance.
int score;
if ((buttonRect.x() < target.right() && target.x() < buttonRect.right())
&& (key == Qt::Key_Up || key == Qt::Key_Down)) {
//one item's is at the vertical of the other
score = (qAbs(p.y() - goal.y()) << 16) + qAbs(p.x() - goal.x());
} else if ((buttonRect.y() < target.bottom() && target.y() < buttonRect.bottom())
&& (key == Qt::Key_Left || key == Qt::Key_Right) ) {
//one item's is at the horizontal of the other
score = (qAbs(p.x() - goal.x()) << 16) + qAbs(p.y() - goal.y());
} else {
score = (1 << 30) + (p.y() - goal.y()) * (p.y() - goal.y()) + (p.x() - goal.x()) * (p.x() - goal.x());
}
if (score > bestScore && candidate)
continue;
switch(key) {
case Qt::Key_Up:
if (p.y() < goal.y()) {
candidate = button;
bestScore = score;
}
break;
case Qt::Key_Down:
if (p.y() > goal.y()) {
candidate = button;
bestScore = score;
}
break;
case Qt::Key_Left:
if (p.x() < goal.x()) {
candidate = button;
bestScore = score;
}
break;
case Qt::Key_Right:
if (p.x() > goal.x()) {
candidate = button;
bestScore = score;
}
break;
}
}
}
if (exclusive
#ifdef QT_KEYPAD_NAVIGATION
&& !QApplication::keypadNavigationEnabled()
#endif
&& candidate
&& fb->d_func()->checked
&& candidate->d_func()->checkable)
candidate->click();
if (candidate) {
if (key == Qt::Key_Up || key == Qt::Key_Left)
candidate->setFocus(Qt::BacktabFocusReason);
else
candidate->setFocus(Qt::TabFocusReason);
}
}