本文整理汇总了C++中QLabel::mapToGlobal方法的典型用法代码示例。如果您正苦于以下问题:C++ QLabel::mapToGlobal方法的具体用法?C++ QLabel::mapToGlobal怎么用?C++ QLabel::mapToGlobal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QLabel
的用法示例。
在下文中一共展示了QLabel::mapToGlobal方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: eventFilter
bool FancyLineEditPrivate::eventFilter(QObject *obj, QEvent *event)
{
if (obj != m_menuLabel)
return QObject::eventFilter(obj, event);
switch (event->type()) {
case QEvent::MouseButtonPress: {
const QMouseEvent *me = static_cast<QMouseEvent *>(event);
if (m_menu) {
m_menu->exec(me->globalPos());
} else {
emit m_lineEdit->buttonClicked();
}
return true;
}
case QEvent::FocusIn:
if (m_menuTabFocusTrigger && m_menu) {
m_lineEdit->setFocus();
m_menu->exec(m_menuLabel->mapToGlobal(m_menuLabel->rect().center()));
return true;
}
default:
break;
}
return QObject::eventFilter(obj, event);
}
示例2: imagePosition
/*! \internal */
QRect QAccessibleDisplay::imagePosition() const
{
QLabel *label = qobject_cast<QLabel *>(widget());
if (!label)
return QRect();
const QPixmap *pixmap = label->pixmap();
if (!pixmap)
return QRect();
return QRect(label->mapToGlobal(label->pos()), label->size());
}
示例3: imagePosition
/*! \internal */
QRect QAccessibleDisplay::imagePosition(QAccessible2::CoordinateType coordType)
{
QLabel *label = qobject_cast<QLabel *>(widget());
if (!label)
return QRect();
const QPixmap *pixmap = label->pixmap();
if (!pixmap)
return QRect();
switch (coordType) {
case QAccessible2::RelativeToScreen:
return QRect(label->mapToGlobal(label->pos()), label->size());
case QAccessible2::RelativeToParent:
return label->geometry();
}
return QRect();
}
示例4: fsw_customContextMenuRequested
void CustomFunctionsPanel::fsw_customContextMenuRequested(QPoint pos)
{
QLabel *label = (QLabel *)sender();
selectedFunction = label->property("index").toInt();
QPoint globalPos = label->mapToGlobal(pos);
const QClipboard *clipboard = QApplication::clipboard();
const QMimeData *mimeData = clipboard->mimeData();
bool hasData = mimeData->hasFormat("application/x-companion-fsw");
QMenu contextMenu;
contextMenu.addAction(CompanionIcon("copy.png"), tr("&Copy"),this,SLOT(fswCopy()),tr("Ctrl+C"));
contextMenu.addAction(CompanionIcon("cut.png"), tr("&Cut"),this,SLOT(fswCut()),tr("Ctrl+X"));
contextMenu.addAction(CompanionIcon("paste.png"), tr("&Paste"),this,SLOT(fswPaste()),tr("Ctrl+V"))->setEnabled(hasData);
contextMenu.addAction(CompanionIcon("clear.png"), tr("&Delete"),this,SLOT(fswDelete()),tr("Delete"));
contextMenu.exec(globalPos);
}
示例5: fileDlg
ISOSelectView::ISOSelectView(QWidget *parent) : QFrame(parent)
{
setObjectName("ISOSelectView");
QVBoxLayout *mainLayout = new QVBoxLayout(this);
mainLayout->setContentsMargins(0, 9, 0, 0);
QLabel *m_title = new QLabel(tr("Select an ISO image file"));
m_title->setFixedHeight(38);
m_title->setStyleSheet("font-size: 26px;");
QLabel *isoIcon = new QLabel(this);
isoIcon->setObjectName("ISOIcon");
isoIcon->setFixedSize(96, 96);
isoIcon->setPixmap(WidgetUtil::getDpiPixmap(":/theme/light/image/media-optical-96px.svg", this));
QLabel *growIcon = new QLabel(this);
growIcon->setObjectName("GrowIcon");
growIcon->setPixmap(WidgetUtil::getDpiPixmap(":/theme/light/image/glow.svg", this));
growIcon->setFixedSize(220, 220);
growIcon->hide();
DropFrame *isoPanel = new DropFrame;
isoPanel->setObjectName("IosPanel");
isoPanel->setFixedSize(412, 322);
QVBoxLayout *isoPanelLayout = new QVBoxLayout(isoPanel);
isoPanelLayout->setMargin(0);
m_fileLabel = new QLabel(tr("Drag an ISO image file and drop it here"));
m_fileLabel->setObjectName("IsoFileName");
// m_fileLabel->setFixedHeight(18);
m_hits = new QLabel(tr("OR"));
m_hits->setObjectName("IsoHits");
m_hits->setFixedHeight(18);
QLabel *spliter = new QLabel;
spliter->setObjectName("IsoSpliter");
spliter->setFixedSize(230, 1);
m_fileSelect = new QLabel();
m_fileSelect->setObjectName("IsoFileSelect");
// m_fileSelect->setFixedHeight(15);
m_fileSelect->setOpenExternalLinks(false);
QString selectText = tr("Select an ISO image file");
QString linkText = QString(s_linkTemplate).arg(selectText).arg(selectText);
m_fileSelect->setText(linkText);
isoPanelLayout->addSpacing(62);
isoPanelLayout->addWidget(isoIcon, 0, Qt::AlignCenter);
isoPanelLayout->addSpacing(5);
isoPanelLayout->addWidget(m_fileLabel, 0, Qt::AlignCenter);
isoPanelLayout->addSpacing(4);
isoPanelLayout->addWidget(m_hits, 0, Qt::AlignCenter);
isoPanelLayout->addSpacing(7);
isoPanelLayout->addWidget(spliter, 0, Qt::AlignCenter);
isoPanelLayout->addSpacing(12);
isoPanelLayout->addWidget(m_fileSelect, 0, Qt::AlignCenter);
isoPanelLayout->addStretch();
m_nextSetp = new SuggestButton();
m_nextSetp->setObjectName("NextStepButton");
m_nextSetp->setText(tr("Next"));
m_nextSetp->setDisabled(true);
mainLayout->addWidget(m_title, 0, Qt::AlignCenter);
mainLayout->addSpacing(24);
mainLayout->addWidget(isoPanel, 0, Qt::AlignCenter);
mainLayout->addStretch();
mainLayout->addWidget(m_nextSetp, 0, Qt::AlignCenter);
this->setStyleSheet(WidgetUtil::getQss(":/theme/light/ISOSelectView.theme"));
#ifdef Q_OS_WIN
m_fileLabel->hide();
spliter->hide();
m_hits->hide();
#endif
connect(isoPanel, &DropFrame::fileAboutAccept, this, [ = ]() {
growIcon->show();
auto center = isoIcon->geometry().center();
growIcon->move(center);
auto topleft = growIcon->mapFromGlobal(isoIcon->mapToGlobal(center));
auto offset = 220 - 96;
topleft.setX(topleft.x() - offset / 2);
topleft.setY(topleft.y() - offset / 2);
growIcon->move(topleft);
isoPanel->setProperty("active", true);
this->style()->unpolish(isoPanel);
this->style()->polish(isoPanel);
});
connect(isoPanel, &DropFrame::fileCancel, this, [ = ]() {
growIcon->hide();
isoPanel->setProperty("active", false);
this->style()->unpolish(isoPanel);
this->style()->polish(isoPanel);
});
connect(m_fileSelect, &QLabel::linkActivated, this, [ = ](const QString & /*link*/) {
QFileDialog fileDlg(this);
//.........这里部分代码省略.........