Qt: QMouseEvent::globalPos() is deprecated in Qt6.

Fix

ui/qt/tcp_stream_dialog.cpp:1669:31: error: 'globalPos' is deprecated: Use globalPosition() [-Werror,-Wdeprecated-declarations]
        ctx_menu_.exec(event->globalPos());
                              ^

and similar warnings.
This commit is contained in:
Gerald Combs 2022-03-22 14:47:18 -07:00 committed by Roland Knall
parent 8c2fdcb80b
commit ea11891f21
10 changed files with 60 additions and 3 deletions

View File

@ -1225,7 +1225,11 @@ void Iax2AnalysisDialog::graphClicked(QMouseEvent *event)
{
updateWidgets();
if (event->button() == Qt::RightButton) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0 ,0)
graph_ctx_menu_.exec(event->globalPosition().toPoint());
#else
graph_ctx_menu_.exec(event->globalPos());
#endif
}
}

View File

@ -1006,7 +1006,11 @@ void IOGraphDialog::graphClicked(QMouseEvent *event)
if (event->button() == Qt::RightButton) {
// XXX We should find some way to get ioPlot to handle a
// contextMenuEvent instead.
#if QT_VERSION >= QT_VERSION_CHECK(6, 0 ,0)
ctx_menu_.exec(event->globalPosition().toPoint());
#else
ctx_menu_.exec(event->globalPos());
#endif
} else if (mouse_drags_) {
if (iop->axisRect()->rect().contains(event->pos())) {
iop->setCursor(QCursor(Qt::ClosedHandCursor));

View File

@ -541,7 +541,11 @@ void LteRlcGraphDialog::graphClicked(QMouseEvent *event)
if (event->button() == Qt::RightButton) {
// XXX We should find some way to get rlcPlot to handle a
// contextMenuEvent instead.
#if QT_VERSION >= QT_VERSION_CHECK(6, 0 ,0)
ctx_menu_->exec(event->globalPosition().toPoint());
#else
ctx_menu_->exec(event->globalPos());
#endif
} else if (mouse_drags_) {
if (rp->axisRect()->rect().contains(event->pos())) {
rp->setCursor(QCursor(Qt::ClosedHandCursor));

View File

@ -965,7 +965,11 @@ void RtpAnalysisDialog::graphClicked(QMouseEvent *event)
{
updateWidgets();
if (event->button() == Qt::RightButton) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0 ,0)
graph_ctx_menu_.popup(event->globalPosition().toPoint());
#else
graph_ctx_menu_.popup(event->globalPos());
#endif
}
}

View File

@ -1105,7 +1105,11 @@ void RtpPlayerDialog::graphClicked(QMouseEvent *event)
{
updateWidgets();
if (event->button() == Qt::RightButton) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0 ,0)
graph_ctx_menu_->exec(event->globalPosition().toPoint());
#else
graph_ctx_menu_->exec(event->globalPos());
#endif
}
}

View File

@ -361,7 +361,11 @@ void SequenceDialog::diagramClicked(QMouseEvent *event)
on_actionGoToPacket_triggered();
break;
case Qt::RightButton:
#if QT_VERSION >= QT_VERSION_CHECK(6, 0 ,0)
ctx_menu_.exec(event->globalPosition().toPoint());
#else
ctx_menu_.exec(event->globalPos());
#endif
break;
default:
break;

View File

@ -1663,7 +1663,11 @@ void TCPStreamDialog::graphClicked(QMouseEvent *event)
if (event->button() == Qt::RightButton) {
// XXX We should find some way to get streamPlot to handle a
// contextMenuEvent instead.
#if QT_VERSION >= QT_VERSION_CHECK(6, 0 ,0)
ctx_menu_.exec(event->globalPosition().toPoint());
#else
ctx_menu_.exec(event->globalPos());
#endif
} else if (mouse_drags_) {
if (sp->axisRect()->rect().contains(event->pos())) {
sp->setCursor(QCursor(Qt::ClosedHandCursor));

View File

@ -42,7 +42,11 @@ void ClickableLabel::mouseReleaseEvent(QMouseEvent * event)
void ClickableLabel::mousePressEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
emit clickedAt(QPoint(event->globalPos()), Qt::LeftButton);
#if QT_VERSION >= QT_VERSION_CHECK(6, 0 ,0)
emit clickedAt(event->globalPosition().toPoint(), Qt::LeftButton);
#else
emit clickedAt(event->globalPos(), Qt::LeftButton);
#endif
}
void ClickableLabel::contextMenuEvent(QContextMenuEvent *event)

View File

@ -102,8 +102,13 @@ void LabelStack::setShrinkable(bool shrinkable)
void LabelStack::mousePressEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
emit mousePressedAt(QPoint(event->globalPos()), Qt::LeftButton);
if (event->button() == Qt::LeftButton) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0 ,0)
emit mousePressedAt(event->globalPosition().toPoint(), Qt::LeftButton);
#else
emit mousePressedAt(event->globalPos(), Qt::LeftButton);
#endif
}
}
void LabelStack::mouseReleaseEvent(QMouseEvent *)

View File

@ -101,7 +101,11 @@ void PacketListHeader::dropEvent(QDropEvent *event)
MainWindow * mw = qobject_cast<MainWindow *>(wsApp->mainWindow());
if (mw)
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 0 ,0)
int idx = logicalIndexAt(event->position().toPoint());
#else
int idx = logicalIndexAt(event->pos());
#endif
mw->insertColumn(data["description"].toString(), data["name"].toString(), idx);
}
@ -118,11 +122,19 @@ void PacketListHeader::mousePressEvent(QMouseEvent *e)
if (e->button() == Qt::LeftButton && sectionIdx < 0)
{
/* No move happening yet */
#if QT_VERSION >= QT_VERSION_CHECK(6, 0 ,0)
int sectIdx = logicalIndexAt(e->position().toPoint().x() - 4, e->position().toPoint().y());
#else
int sectIdx = logicalIndexAt(e->localPos().x() - 4, e->localPos().y());
#endif
QString headerName = model()->headerData(sectIdx, orientation()).toString();
lastSize = sectionSize(sectIdx);
#if QT_VERSION >= QT_VERSION_CHECK(6, 0 ,0)
QToolTip::showText(e->globalPosition().toPoint(), QString("Width: %1").arg(sectionSize(sectIdx)));
#else
QToolTip::showText(e->globalPos(), QString("Width: %1").arg(sectionSize(sectIdx)));
#endif
}
QHeaderView::mousePressEvent(e);
}
@ -138,7 +150,11 @@ void PacketListHeader::mouseMoveEvent(QMouseEvent *e)
else if (e->buttons() & Qt::LeftButton)
{
/* section being moved */
#if QT_VERSION >= QT_VERSION_CHECK(6, 0 ,0)
int triggeredSection = logicalIndexAt(e->position().toPoint().x() - 4, e->position().toPoint().y());
#else
int triggeredSection = logicalIndexAt(e->localPos().x() - 4, e->localPos().y());
#endif
if (sectionIdx < 0)
sectionIdx = triggeredSection;
@ -147,7 +163,11 @@ void PacketListHeader::mouseMoveEvent(QMouseEvent *e)
/* Only run for the current moving section after a change */
QString headerName = model()->headerData(sectionIdx, orientation()).toString();
lastSize = sectionSize(sectionIdx);
#if QT_VERSION >= QT_VERSION_CHECK(6, 0 ,0)
QToolTip::showText(e->globalPosition().toPoint(), QString("Width: %1").arg(lastSize));
#else
QToolTip::showText(e->globalPos(), QString("Width: %1").arg(lastSize));
#endif
}
}
QHeaderView::mouseMoveEvent(e);