mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-23 15:06:32 +00:00
Custom render tooltip events in RDHeaderView
* Because Qt is awful at customising controls, the functions used to fetch the index of sections are not virtual so the internal QHeaderView version doesn't get the right sections when we have column grouping enabled.
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
#include <QPixmap>
|
||||
#include <QPointer>
|
||||
#include <QScrollBar>
|
||||
#include <QToolTip>
|
||||
#include <QTreeView>
|
||||
#include "Code/QRDUtils.h"
|
||||
|
||||
@@ -864,6 +865,28 @@ void RDHeaderView::paintEvent(QPaintEvent *e)
|
||||
}
|
||||
}
|
||||
|
||||
bool RDHeaderView::viewportEvent(QEvent *e)
|
||||
{
|
||||
if(e->type() == QEvent::ToolTip)
|
||||
{
|
||||
QHelpEvent *h = (QHelpEvent *)e;
|
||||
int section = logicalIndexAt(h->pos());
|
||||
if(section >= 0)
|
||||
{
|
||||
QAbstractItemModel *m = this->model();
|
||||
|
||||
QVariant tooltip = m->headerData(section, orientation(), Qt::ToolTipRole);
|
||||
if(tooltip.isValid())
|
||||
{
|
||||
QToolTip::showText(h->globalPos(), tooltip.toString(), this);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return QHeaderView::viewportEvent(e);
|
||||
}
|
||||
|
||||
void RDHeaderView::paintSection(QPainter *painter, const QRect &rect, int section) const
|
||||
{
|
||||
if(!m_customSizing)
|
||||
|
||||
@@ -79,6 +79,7 @@ protected:
|
||||
void mouseMoveEvent(QMouseEvent *event) override;
|
||||
void mouseReleaseEvent(QMouseEvent *event) override;
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
bool viewportEvent(QEvent *e) override;
|
||||
|
||||
void paintSection(QPainter *painter, const QRect &rect, int section) const override;
|
||||
void currentChanged(const QModelIndex ¤t, const QModelIndex &old) override;
|
||||
|
||||
Reference in New Issue
Block a user