In QListView , QStandardItemModel, QStandartItem statusTip does not show up in the status line

290 views
Skip to first unread message

ynedelin

unread,
Jun 16, 2015, 3:22:13 PM6/16/15
to python_in...@googlegroups.com
hey guys,
In QListView QStandartItem statusTip does not show up in the status line

I am in maya 2015 using pyside

I have a QListView with a QStandardItemModel with several appended rows of QStandardItem

model = QtGui.QStandardItemModel.
item = QtGui.QStandardItem(k)
model.appendRow(item)
item.setToolTip("this is tool tip")
item.setStatusTip("this is status tip")

tool tip shows up with the mouse hoovering over the item but the status line remains empty.

Any ideas ?

Thanks
Yury


Justin Israel

unread,
Jun 16, 2015, 5:39:49 PM6/16/15
to python_in...@googlegroups.com
Good question. I wonder why that isn't working as expected. While it does store a status tip value that can be retrieved, it doesn't seem to propagate that. Maybe someone else knows an exact reason... but you could work around it if you really wanted a status tip to show. QListWidget has an explicit event for an itemEntered, and with QListView you would have to track it yourself:
from PySide import QtCore, QtGui

class ListView(QtGui.QListView):

    def __init__(self, *args, **kwargs):
        super(ListView, self).__init__(*args, **kwargs)
        self.__statusBar = None

    def mouseMoveEvent(self, e):
        if self.__statusBar:
            idx = self.indexAt(e.pos())
            if idx.isValid():
                tip = idx.data(QtCore.Qt.StatusTipRole)
                self.__statusBar.showMessage(tip, 5*1000)
            else:
                self.__statusBar.clearMessage()

    def setStatusBar(self, bar):
        ''' Set a reference to a QStatusBar, for messages '''
        self.__statusBar = bar
        self.setMouseTracking(bool(bar))

# Usage
win = QtGui.QMainWindow()
listW = ListView(win)
listW.setStatusBar(win.statusBar())
mod = QtGui.QStandardItemModel(listW)
listW.setModel(mod)

item = QtGui.QStandardItem("name")
item.setToolTip("tooltip")
item.setStatusTip("status tip")
mod.appendRow(item)

win.setCentralWidget(listW)
win.show()
win.raise_()
I actually do something a little bit similar to this, when I have my own random QStatusBar within a widget layout (not the main status bar) and I want to do custom status bar messages from child widgets.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/78bbbd46-fe77-41b7-84a9-8b3b9161e21a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Anthony Tan

unread,
Jun 17, 2015, 2:41:42 AM6/17/15
to python_in...@googlegroups.com
Ha. I just went aaaaal the way into the event model and back out again, subclassing QMainWindow, QListView, etc etc and inspecting things trying to work out what was up...and then I noticed that stock QListView doesn't start off tracking mouse movements.
 
*sigh*
 
Two things.
 
- First, just do a setMouseTracking(True) call on your QListView.
 
- Second, when you say status line, I presume you mean the main window status line as in, the Maya master window? If so, this should work.
 
If you're expecting it the QMainWindow's status bar, not so much. Works as expected in Nuke, but I haven't really hacked around much in Maya lately so can't shed much light on it there or how to easily patch into that. I may have a play this w/e if the rain keeps up..

Justin Israel

unread,
Jun 17, 2015, 3:03:02 AM6/17/15
to python_in...@googlegroups.com
Wow, I feel dumb. That does work perfectly. I must have forgotten to enable mouse tracking when I initially tested it, and then enabled it later when I created the workaround :-)

Nice call, Anthony.

Anthony Tan

unread,
Jun 17, 2015, 3:23:25 AM6/17/15
to python_in...@googlegroups.com
You and me both! I sort of glossed over it while I was testing, then decided to reimplement mousemove events just incase.. and then then penny dropped.
 
Had to get up from the computer to avoid berating myself too obviously :D

yury nedelin

unread,
Jun 17, 2015, 11:40:47 AM6/17/15
to python_in...@googlegroups.com
Thanks guys,
Looks there is a nice solution, I will give it a try when I get into the office this morning.
Yury


Reply all
Reply to author
Forward
0 new messages