QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
Loading...
Searching...
No Matches
qgstooltipcombobox.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgscheckablecombobox.cpp
3 ------------------------
4 begin : May 25, 2023
5 copyright : (C) 2017 by Mathieu Pellerin
6 email : mathieu at opengis dot ch
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#include "qgstooltipcombobox.h"
19
20#include <QEvent>
21#include <QHelpEvent>
22#include <QPoint>
23#include <QToolTip>
24
25
27 : QComboBox( parent )
28{
29}
30
31bool QgsToolTipComboBox::event( QEvent *event )
32{
33 if ( event->type() == QEvent::ToolTip )
34 {
35 const QString description = currentData( Qt::ToolTipRole ).toString();
36 if ( !description.isEmpty() )
37 {
38 QHelpEvent *helpEvent = static_cast< QHelpEvent *>( event );
39 QPoint pos = mapToGlobal( helpEvent->pos() );
40 QToolTip::showText( pos, description );
41 }
42 return true;
43 }
44 return QComboBox::event( event );
45}
bool event(QEvent *event) override
QgsToolTipComboBox(QWidget *parent=nullptr)
Constructor for QgsToolTipComboBox.