Port QT_NO_TOOLTIP to QT_CONFIG(tooltip)

We remove the QT_NO_TOOLTIP check from qstandarditemmodel.h, because as
the 'tooltip' feature is in QtWidgets, we cannot use it properly in
QtGui. Also this affects just two non-virtual inline methods, i.e. it
has no effect on library size.

Task-number: QTBUG-82785
Change-Id: Ic166f14fb1cf3e9dd789573a6b9db6a87fb50e10
Reviewed-by: Tasuku Suzuki <tasuku.suzuki@kdab.com>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
This commit is contained in:
Joerg Bornemann 2020-04-07 17:49:43 +02:00
parent fbb7c98e91
commit 1c80d056e4
37 changed files with 96 additions and 76 deletions

View File

@ -79,12 +79,10 @@ public:
}
inline void setIcon(const QIcon &icon);
#ifndef QT_NO_TOOLTIP
inline QString toolTip() const {
return qvariant_cast<QString>(data(Qt::ToolTipRole));
}
inline void setToolTip(const QString &toolTip);
#endif
#ifndef QT_NO_STATUSTIP
inline QString statusTip() const {
@ -260,10 +258,8 @@ inline void QStandardItem::setText(const QString &atext)
inline void QStandardItem::setIcon(const QIcon &aicon)
{ setData(aicon, Qt::DecorationRole); }
#ifndef QT_NO_TOOLTIP
inline void QStandardItem::setToolTip(const QString &atoolTip)
{ setData(atoolTip, Qt::ToolTipRole); }
#endif
#ifndef QT_NO_STATUSTIP
inline void QStandardItem::setStatusTip(const QString &astatusTip)

View File

@ -57,7 +57,9 @@
#endif
#include <qstyle.h>
#include <qstyleoption.h>
#if QT_CONFIG(tooltip)
#include <qtooltip.h>
#endif
#if QT_CONFIG(whatsthis)
#include <qwhatsthis.h>
#endif

View File

@ -48,7 +48,9 @@
#if QT_CONFIG(label)
#include "qlabel.h"
#endif
#if QT_CONFIG(tooltip)
#include "qtooltip.h"
#endif
#if QT_CONFIG(whatsthis)
#include "qwhatsthis.h"
#endif
@ -425,7 +427,7 @@ QString QAccessibleWidget::text(QAccessible::Text t) const
break;
case QAccessible::Description:
str = widget()->accessibleDescription();
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
if (str.isEmpty())
str = widget()->toolTip();
#endif

View File

@ -545,7 +545,7 @@ void *QAccessibleDisplay::interface_cast(QAccessible::InterfaceType t)
/*! \internal */
QString QAccessibleDisplay::imageDescription() const
{
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
return widget()->toolTip();
#else
return QString();

View File

@ -2239,7 +2239,7 @@ bool QGraphicsItem::isBlockedByModalPanel(QGraphicsItem **blockingPanel) const
return false;
}
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
/*!
Returns the item's tool tip, or an empty QString if no tool tip has been
set.
@ -2263,7 +2263,7 @@ void QGraphicsItem::setToolTip(const QString &toolTip)
d_ptr->setExtra(QGraphicsItemPrivate::ExtraToolTip, toolTipVariant.toString());
itemChange(ItemToolTipHasChanged, toolTipVariant);
}
#endif // QT_NO_TOOLTIP
#endif // QT_CONFIG(tooltip)
#ifndef QT_NO_CURSOR
/*!

View File

@ -191,7 +191,7 @@ public:
void setPanelModality(PanelModality panelModality);
bool isBlockedByModalPanel(QGraphicsItem **blockingPanel = nullptr) const;
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
QString toolTip() const;
void setToolTip(const QString &toolTip);
#endif

View File

@ -890,7 +890,7 @@ bool QGraphicsProxyWidget::event(QEvent *event)
}
break;
}
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
case QEvent::GraphicsSceneHelp: {
// Propagate the help event (for tooltip) to the widget under mouse
if (d->lastWidgetUnderMouse) {
@ -981,7 +981,7 @@ bool QGraphicsProxyWidget::eventFilter(QObject *object, QEvent *event)
d->styleChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
}
break;
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
case QEvent::ToolTipChange:
// Propagate tooltip change to the proxy.
if (!d->tooltipChangeMode) {

View File

@ -238,7 +238,9 @@
#include <QtGui/qpolygon.h>
#include <QtGui/qtouchdevice.h>
#include <QtWidgets/qstyleoption.h>
#if QT_CONFIG(tooltip)
#include <QtWidgets/qtooltip.h>
#endif
#include <QtGui/qtransform.h>
#include <QtGui/qinputmethod.h>
#include <private/qapplication_p.h>
@ -3729,7 +3731,7 @@ void QGraphicsScene::focusOutEvent(QFocusEvent *focusEvent)
*/
void QGraphicsScene::helpEvent(QGraphicsSceneHelpEvent *helpEvent)
{
#ifdef QT_NO_TOOLTIP
#if !QT_CONFIG(tooltip)
Q_UNUSED(helpEvent);
#else
// Find the first item that does tooltips
@ -3860,7 +3862,7 @@ bool QGraphicsScenePrivate::dispatchHoverEvent(QGraphicsSceneHoverEvent *hoverEv
*/
void QGraphicsScenePrivate::leaveScene(QWidget *viewport)
{
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
QToolTip::hideText();
#endif
QGraphicsView *view = qobject_cast<QGraphicsView *>(viewport->parent());

View File

@ -2888,7 +2888,7 @@ bool QGraphicsView::viewportEvent(QEvent *event)
QCoreApplication::sendEvent(d->scene, event);
break;
}
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
case QEvent::ToolTip: {
QHelpEvent *toolTip = static_cast<QHelpEvent *>(event);
QGraphicsSceneHelpEvent helpEvent(QEvent::GraphicsSceneHelp);

View File

@ -45,7 +45,9 @@
#if QT_CONFIG(whatsthis)
#include <qwhatsthis.h>
#endif
#if QT_CONFIG(tooltip)
#include <qtooltip.h>
#endif
#include <qevent.h>
#include <qstring.h>
#include <qdebug.h>
@ -369,7 +371,7 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event,
return false;
Q_D(QAbstractItemDelegate);
switch (event->type()) {
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
case QEvent::ToolTip: {
QHelpEvent *he = static_cast<QHelpEvent*>(event);
const int precision = inherits("QItemDelegate") ? 10 : 6; // keep in sync with DBL_DIG in qitemdelegate.cpp

View File

@ -49,7 +49,9 @@
#endif
#include <qevent.h>
#include <qscrollbar.h>
#if QT_CONFIG(tooltip)
#include <qtooltip.h>
#endif
#include <qdatetime.h>
#if QT_CONFIG(lineedit)
#include <qlineedit.h>

View File

@ -45,7 +45,9 @@
#include <qevent.h>
#include <qpainter.h>
#include <qscrollbar.h>
#if QT_CONFIG(tooltip)
#include <qtooltip.h>
#endif
#if QT_CONFIG(whatsthis)
#include <qwhatsthis.h>
#endif
@ -2756,7 +2758,7 @@ bool QHeaderView::viewportEvent(QEvent *e)
{
Q_D(QHeaderView);
switch (e->type()) {
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
case QEvent::ToolTip: {
QHelpEvent *he = static_cast<QHelpEvent*>(e);
int logical = logicalIndexAt(he->pos());

View File

@ -93,7 +93,7 @@ public:
{ return data(Qt::StatusTipRole).toString(); }
inline void setStatusTip(const QString &statusTip);
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
inline QString toolTip() const
{ return data(Qt::ToolTipRole).toString(); }
inline void setToolTip(const QString &toolTip);
@ -165,7 +165,7 @@ inline void QListWidgetItem::setIcon(const QIcon &aicon)
inline void QListWidgetItem::setStatusTip(const QString &astatusTip)
{ setData(Qt::StatusTipRole, astatusTip); }
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
inline void QListWidgetItem::setToolTip(const QString &atoolTip)
{ setData(Qt::ToolTipRole, atoolTip); }
#endif

View File

@ -113,7 +113,7 @@ public:
{ return data(Qt::StatusTipRole).toString(); }
inline void setStatusTip(const QString &statusTip);
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
inline QString toolTip() const
{ return data(Qt::ToolTipRole).toString(); }
inline void setToolTip(const QString &toolTip);
@ -187,7 +187,7 @@ inline void QTableWidgetItem::setIcon(const QIcon &aicon)
inline void QTableWidgetItem::setStatusTip(const QString &astatusTip)
{ setData(Qt::StatusTipRole, astatusTip); }
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
inline void QTableWidgetItem::setToolTip(const QString &atoolTip)
{ setData(Qt::ToolTipRole, atoolTip); }
#endif

View File

@ -113,7 +113,7 @@ public:
{ return data(column, Qt::StatusTipRole).toString(); }
inline void setStatusTip(int column, const QString &statusTip);
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
inline QString toolTip(int column) const
{ return data(column, Qt::ToolTipRole).toString(); }
inline void setToolTip(int column, const QString &toolTip);
@ -220,7 +220,7 @@ inline void QTreeWidgetItem::setStatusTip(int column, const QString &astatusTip)
{ setData(column, Qt::StatusTipRole, astatusTip); }
#endif
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
inline void QTreeWidgetItem::setToolTip(int column, const QString &atoolTip)
{ setData(column, Qt::ToolTipRole, atoolTip); }
#endif

View File

@ -58,7 +58,9 @@
#include "qstyle.h"
#include "qstyleoption.h"
#include "qstylefactory.h"
#if QT_CONFIG(tooltip)
#include "qtooltip.h"
#endif
#include "qtranslator.h"
#include "qvariant.h"
#include "qwidget.h"
@ -515,7 +517,7 @@ void QApplicationPrivate::init()
void qt_init_tooltip_palette()
{
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
if (const QPalette *toolTipPalette = QGuiApplicationPrivate::platformTheme()->palette(QPlatformTheme::ToolTipPalette))
QToolTip::setPalette(*toolTipPalette);
#endif
@ -3157,7 +3159,7 @@ QT_WARNING_POP
break;
#endif // QT_CONFIG(tabletevent)
#if !defined(QT_NO_TOOLTIP) || QT_CONFIG(whatsthis)
#if QT_CONFIG(tooltip) || QT_CONFIG(whatsthis)
case QEvent::ToolTip:
case QEvent::WhatsThis:
case QEvent::QueryWhatsThis:

View File

@ -57,7 +57,6 @@
#include <qpa/qplatformcursor.h>
#include <private/qstylesheetstyle_p.h>
#ifndef QT_NO_TOOLTIP
#include <qlabel.h>
#include <QtWidgets/private/qlabel_p.h>
#include <QtGui/private/qhighdpiscaling_p.h>
@ -628,4 +627,3 @@ void QToolTip::setFont(const QFont &font)
QT_END_NAMESPACE
#include "qtooltip.moc"
#endif // QT_NO_TOOLTIP

View File

@ -43,11 +43,9 @@
#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qwidget.h>
QT_REQUIRE_CONFIG(tooltip);
QT_BEGIN_NAMESPACE
#ifndef QT_NO_TOOLTIP
class Q_WIDGETS_EXPORT QToolTip
{
QToolTip() = delete;
@ -67,8 +65,6 @@ public:
static void setFont(const QFont &);
};
#endif // QT_NO_TOOLTIP
QT_END_NAMESPACE
#endif // QTOOLTIP_H

View File

@ -64,7 +64,9 @@
#include <qpa/qplatformwindow.h>
#include "private/qwidgetwindow_p.h"
#include "qpainter.h"
#if QT_CONFIG(tooltip)
#include "qtooltip.h"
#endif
#if QT_CONFIG(whatsthis)
#include "qwhatsthis.h"
#endif
@ -147,7 +149,7 @@ QWidgetPrivate::QWidgetPrivate(int version)
#if !defined(QT_NO_IM)
, imHints(Qt::ImhNone)
#endif
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
, toolTipDuration(-1)
#endif
, directFontResolveMask(0)
@ -8972,7 +8974,7 @@ bool QWidget::event(QEvent *event)
}
}
break;
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
case QEvent::ToolTip:
if (!d->toolTip.isEmpty())
QToolTip::showText(static_cast<QHelpEvent*>(event)->globalPos(), d->toolTip, this, QRect(), d->toolTipDuration);
@ -11237,7 +11239,7 @@ void QWidgetPrivate::setWindowModified_helper()
}
}
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
/*!
\property QWidget::toolTip
@ -11294,7 +11296,7 @@ int QWidget::toolTipDuration() const
return d->toolTipDuration;
}
#endif // QT_NO_TOOLTIP
#endif // QT_CONFIG(tooltip)
#if QT_CONFIG(statustip)

View File

@ -182,7 +182,7 @@ class Q_WIDGETS_EXPORT QWidget : public QObject, public QPaintDevice
Q_PROPERTY(QString windowIconText READ windowIconText WRITE setWindowIconText NOTIFY windowIconTextChanged) // deprecated
Q_PROPERTY(double windowOpacity READ windowOpacity WRITE setWindowOpacity)
Q_PROPERTY(bool windowModified READ isWindowModified WRITE setWindowModified)
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
Q_PROPERTY(QString toolTip READ toolTip WRITE setToolTip)
Q_PROPERTY(int toolTipDuration READ toolTipDuration WRITE setToolTipDuration)
#endif
@ -382,7 +382,7 @@ public:
qreal windowOpacity() const;
bool isWindowModified() const;
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
void setToolTip(const QString &);
QString toolTip() const;
void setToolTipDuration(int msec);

View File

@ -654,7 +654,7 @@ public:
// Implicit pointers (shared_null/shared_empty).
QRegion opaqueChildren;
QRegion dirty;
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
QString toolTip;
int toolTipDuration;
#endif

View File

@ -5351,7 +5351,7 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget
case SH_Menu_SupportsSections:
ret = false;
break;
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
case SH_ToolTip_WakeUpDelay:
ret = 700;
break;

View File

@ -65,7 +65,9 @@
#include "private/qmath_p.h"
#include <qabstractscrollarea.h>
#include "private/qabstractscrollarea_p.h"
#if QT_CONFIG(tooltip)
#include <qtooltip.h>
#endif
#include <qshareddata.h>
#if QT_CONFIG(toolbutton)
#include <qtoolbutton.h>
@ -987,7 +989,7 @@ QRenderRule::QRenderRule(const QVector<Declaration> &declarations, const QObject
int adj = -255;
hasFont = v.extractFont(&font, &adj);
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
if (object && qstrcmp(object->metaObject()->className(), "QTipLabel") == 0)
palette = QToolTip::palette();
#endif
@ -1508,7 +1510,7 @@ public:
if (isNullNode(node))
return QStringList();
const QMetaObject *metaObject = OBJECT_PTR(node)->metaObject();
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
if (qstrcmp(metaObject->className(), "QTipLabel") == 0)
return QStringList(QLatin1String("QToolTip"));
#endif
@ -1560,7 +1562,7 @@ public:
if (isNullNode(node))
return false;
const QMetaObject *metaObject = OBJECT_PTR(node)->metaObject();
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
if (qstrcmp(metaObject->className(), "QTipLabel") == 0)
return nodeName == QLatin1String("QToolTip");
#endif

View File

@ -308,7 +308,7 @@ void QSystemTrayIconPrivate::updateToolTip_sys()
}
if (!sys)
return;
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
sys->setToolTip(toolTip);
#endif
}

View File

@ -2109,7 +2109,7 @@ bool QDockAreaLayoutInfo::updateTabBar() const
quintptr id = tabId(item);
if (tab_idx == tabBar->count()) {
tabBar->insertTab(tab_idx, title);
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
tabBar->setTabToolTip(tab_idx, title);
#endif
tabBar->setTabData(tab_idx, id);
@ -2119,7 +2119,7 @@ bool QDockAreaLayoutInfo::updateTabBar() const
tabBar->removeTab(tab_idx);
else {
tabBar->insertTab(tab_idx, title);
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
tabBar->setTabToolTip(tab_idx, title);
#endif
tabBar->setTabData(tab_idx, id);
@ -2128,7 +2128,7 @@ bool QDockAreaLayoutInfo::updateTabBar() const
if (title != tabBar->tabText(tab_idx)) {
tabBar->setTabText(tab_idx, title);
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
tabBar->setTabToolTip(tab_idx, title);
#endif
}

View File

@ -154,7 +154,9 @@
#if QT_CONFIG(whatsthis)
#include <QWhatsThis>
#endif
#if QT_CONFIG(tooltip)
#include <QToolTip>
#endif
#if QT_CONFIG(mainwindow)
#include <QMainWindow>
#endif
@ -290,7 +292,7 @@ static inline bool isHoverControl(QStyle::SubControl control)
return control != QStyle::SC_None && control != QStyle::SC_TitleBarLabel;
}
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
static void showToolTip(QHelpEvent *helpEvent, QWidget *widget, const QStyleOptionComplex &opt,
QStyle::ComplexControl complexControl, QStyle::SubControl subControl)
{
@ -355,7 +357,7 @@ static void showToolTip(QHelpEvent *helpEvent, QWidget *widget, const QStyleOpti
const QRect rect = widget->style()->subControlRect(complexControl, &opt, subControl, widget);
QToolTip::showText(helpEvent->globalPos(), toolTip, widget, rect);
}
#endif // QT_NO_TOOLTIP
#endif // QT_CONFIG(tooltip)
namespace QMdi {
/*
@ -416,7 +418,7 @@ bool ControlLabel::event(QEvent *event)
updateWindowIcon();
setFixedSize(label.size());
}
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
else if (event->type() == QEvent::ToolTip) {
QStyleOptionTitleBar options;
options.initFrom(this);
@ -673,14 +675,14 @@ void ControllerWidget::leaveEvent(QEvent * /*event*/)
*/
bool ControllerWidget::event(QEvent *event)
{
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
if (event->type() == QEvent::ToolTip) {
QStyleOptionComplex opt;
initStyleOption(&opt);
QHelpEvent *helpEvent = static_cast<QHelpEvent *>(event);
showToolTip(helpEvent, this, opt, QStyle::CC_MdiControls, getSubControl(helpEvent->pos()));
}
#endif // QT_NO_TOOLTIP
#endif // QT_CONFIG(tooltip)
return QWidget::event(event);
}
@ -2874,7 +2876,7 @@ bool QMdiSubWindow::event(QEvent *event)
case QEvent::FontChange:
d->font = font();
break;
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
case QEvent::ToolTip:
showToolTip(static_cast<QHelpEvent *>(event), this, d->titleBarOptions(),
QStyle::CC_TitleBar, d->hoveredSubControl);

View File

@ -73,7 +73,9 @@
#include "qtoolbutton.h"
#endif
#include "qpushbutton.h"
#if QT_CONFIG(tooltip)
#include "qtooltip.h"
#endif
#include <qwindow.h>
#include <private/qpushbutton_p.h>
#include <private/qaction_p.h>
@ -3029,7 +3031,7 @@ QMenu::event(QEvent *e)
if (d->currentAction)
d->popupAction(d->currentAction, 0, false);
break;
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
case QEvent::ToolTip:
if (d->toolTipsVisible) {
const QHelpEvent *ev = static_cast<const QHelpEvent*>(e);
@ -3041,7 +3043,7 @@ QMenu::event(QEvent *e)
}
}
break;
#endif // QT_NO_TOOLTIP
#endif // QT_CONFIG(tooltip)
#if QT_CONFIG(whatsthis)
case QEvent::QueryWhatsThis:
e->setAccepted(d->whatsThis.size());

View File

@ -52,7 +52,9 @@
#if QT_CONFIG(tabwidget)
#include "qtabwidget.h"
#endif
#if QT_CONFIG(tooltip)
#include "qtooltip.h"
#endif
#if QT_CONFIG(whatsthis)
#include "qwhatsthis.h"
#endif
@ -1280,7 +1282,7 @@ void QTabBar::setTabIcon(int index, const QIcon & icon)
}
}
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
/*!
Sets the tool tip of the tab at position \a index to \a tip.
*/
@ -1302,7 +1304,7 @@ QString QTabBar::tabToolTip(int index) const
return tab->toolTip;
return QString();
}
#endif // QT_NO_TOOLTIP
#endif // QT_CONFIG(tooltip)
#if QT_CONFIG(whatsthis)
/*!
@ -1711,7 +1713,7 @@ bool QTabBar::event(QEvent *event)
update(oldHoverRect);
return true;
}
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
case QEvent::ToolTip:
if (const QTabBarPrivate::Tab *tab = d->at(tabAt(static_cast<QHelpEvent*>(event)->pos()))) {
if (!tab->toolTip.isEmpty()) {
@ -1720,7 +1722,7 @@ bool QTabBar::event(QEvent *event)
}
}
break;
#endif // QT_NO_TOOLTIP
#endif // QT_CONFIG(tooltip)
#if QT_CONFIG(whatsthis)
case QEvent::QEvent::QueryWhatsThis: {
const QTabBarPrivate::Tab *tab = d->at(d->indexAtPos(static_cast<QHelpEvent*>(event)->pos()));
@ -2785,7 +2787,7 @@ CloseButton::CloseButton(QWidget *parent)
#ifndef QT_NO_CURSOR
setCursor(Qt::ArrowCursor);
#endif
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
setToolTip(tr("Close Tab"));
#endif
resize(sizeHint());

View File

@ -120,7 +120,7 @@ public:
Qt::TextElideMode elideMode() const;
void setElideMode(Qt::TextElideMode mode);
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
void setTabToolTip(int index, const QString &tip);
QString tabToolTip(int index) const;
#endif

View File

@ -117,7 +117,7 @@ public:
bool visible;
int shortcutId;
QString text;
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
QString toolTip;
#endif
#if QT_CONFIG(whatsthis)

View File

@ -1209,7 +1209,7 @@ int QTabWidget::count() const
return d->tabs->count();
}
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
/*!
Sets the tab tool tip for the page at position \a index to \a tip.
@ -1232,7 +1232,7 @@ QString QTabWidget::tabToolTip(int index) const
Q_D(const QTabWidget);
return d->tabs->tabToolTip(index);
}
#endif // QT_NO_TOOLTIP
#endif // QT_CONFIG(tooltip)
#if QT_CONFIG(whatsthis)
/*!

View File

@ -91,7 +91,7 @@ public:
QIcon tabIcon(int index) const;
void setTabIcon(int index, const QIcon & icon);
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
void setTabToolTip(int index, const QString & tip);
QString tabToolTip(int index) const;
#endif

View File

@ -47,7 +47,9 @@
#include <qscrollarea.h>
#include <qstyle.h>
#include <qstyleoption.h>
#if QT_CONFIG(tooltip)
#include <qtooltip.h>
#endif
#include <qabstractbutton.h>
#include <private/qmemory_p.h>
@ -96,7 +98,7 @@ public:
inline void setText(const QString &text) { button->setText(text); }
inline void setIcon(const QIcon &is) { button->setIcon(is); }
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
inline void setToolTip(const QString &tip) { button->setToolTip(tip); }
inline QString toolTip() const { return button->toolTip(); }
#endif
@ -638,7 +640,7 @@ void QToolBox::setItemIcon(int index, const QIcon &icon)
c->setIcon(icon);
}
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
/*!
Sets the tooltip of the item at position \a index to \a toolTip.
*/
@ -650,7 +652,7 @@ void QToolBox::setItemToolTip(int index, const QString &toolTip)
if (c)
c->setToolTip(toolTip);
}
#endif // QT_NO_TOOLTIP
#endif // QT_CONFIG(tooltip)
/*!
Returns \c true if the item at position \a index is enabled; otherwise returns \c false.
@ -687,7 +689,7 @@ QIcon QToolBox::itemIcon(int index) const
return (c ? c->icon() : QIcon());
}
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
/*!
Returns the tooltip of the item at position \a index, or an
empty string if \a index is out of range.
@ -699,7 +701,7 @@ QString QToolBox::itemToolTip(int index) const
const QToolBoxPrivate::Page *c = d->page(index);
return (c ? c->toolTip() : QString());
}
#endif // QT_NO_TOOLTIP
#endif // QT_CONFIG(tooltip)
/*! \reimp */
void QToolBox::showEvent(QShowEvent *e)

View File

@ -76,7 +76,7 @@ public:
void setItemIcon(int index, const QIcon &icon);
QIcon itemIcon(int index) const;
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
void setItemToolTip(int index, const QString &toolTip);
QString itemToolTip(int index) const;
#endif

View File

@ -49,7 +49,9 @@
#include <qpointer.h>
#include <qstyle.h>
#include <qstyleoption.h>
#if QT_CONFIG(tooltip)
#include <qtooltip.h>
#endif
#if QT_CONFIG(mainwindow)
#include <qmainwindow.h>
#endif
@ -944,7 +946,7 @@ void QToolButton::setDefaultAction(QAction *action)
buttonText.replace(QLatin1String("&"), QLatin1String("&&"));
setText(buttonText);
setIcon(action->icon());
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
setToolTip(action->toolTip());
#endif
#if QT_CONFIG(statustip)

View File

@ -84,7 +84,9 @@
#include <qurl.h>
#include <qdesktopservices.h>
#include <qinputmethod.h>
#if QT_CONFIG(tooltip)
#include <qtooltip.h>
#endif
#include <qstyleoption.h>
#if QT_CONFIG(lineedit)
#include <QtWidgets/qlineedit.h>
@ -1074,13 +1076,13 @@ void QWidgetTextControl::processEvent(QEvent *e, const QTransform &transform, QW
d->isEnabled = e->isAccepted();
break;
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
case QEvent::ToolTip: {
QHelpEvent *ev = static_cast<QHelpEvent *>(e);
d->showToolTip(ev->globalPos(), transform.map(ev->pos()), contextWidget);
break;
}
#endif // QT_NO_TOOLTIP
#endif // QT_CONFIG(tooltip)
#if QT_CONFIG(draganddrop)
case QEvent::DragEnter: {
@ -2948,7 +2950,7 @@ void QWidgetTextControlPrivate::activateLinkUnderCursor(QString href)
emit q_func()->linkActivated(href);
}
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
void QWidgetTextControlPrivate::showToolTip(const QPoint &globalPos, const QPointF &pos, QWidget *contextWidget)
{
const QString toolTip = q_func()->cursorForPosition(pos).charFormat().toolTip();
@ -2956,7 +2958,7 @@ void QWidgetTextControlPrivate::showToolTip(const QPoint &globalPos, const QPoin
return;
QToolTip::showText(globalPos, toolTip, contextWidget);
}
#endif // QT_NO_TOOLTIP
#endif // QT_CONFIG(tooltip)
bool QWidgetTextControlPrivate::isPreediting() const
{

View File

@ -171,7 +171,7 @@ public:
void activateLinkUnderCursor(QString href = QString());
#ifndef QT_NO_TOOLTIP
#if QT_CONFIG(tooltip)
void showToolTip(const QPoint &globalPos, const QPointF &pos, QWidget *contextWidget);
#endif