主题已经很明显了,我们直接代码见:
1.
setMouseTracking(true);
设置QTableView可以随时接收鼠标的移动时间。
2.
connect(this, SIGNAL(entered(const QModelIndex &)), this,SLOT(showToolTip(const QModelIndex &)));
添加signal获得当前鼠标在哪个modelIndex中。
3. 接下来只要在showToolTip中实现想要的显示即可。
void showToolTip(const QModelIndex &index)
{
switch (index.column())
{
case 1