PDA

View Full Version : Mimicking mouseover behaviour in Qt Assistant 'Open Pages' dock



russdot
27th April 2012, 02:12
Specifically, the 'X' to close a tab which appears beside the text when hovering over a particular row. I would like to add some QStandardItems to a QTreeView and have a couple of functional 'buttons' (similar to the 'X' mentioned above) for controlling layer order (up and down arrows) as well as deleting a layer (an 'X').

Can anyone suggest a good way to approach this problem? I am fairly comfortable with the basic functionality of QTreeView / QStandardItem / QStandardItemModel, but don't really know how I can add buttons (or button-like images) to a row entry in a QTreeView.

Thanks!

ChrisW67
27th April 2012, 04:04
What "Open Pages" dock Qt Assistant? I have only Contents, Index, and Bookmarks dock widgets in Assistant. Perhaps you mean the fixed left panel in Qt Creator's Help context?

The easiest way to find out how this has been done would be to look at the Qt Creator source code.

russdot
27th April 2012, 14:14
When you open a new tab in Qt Assistant (CTRL+T), the open pages dock window (ALT+P) shows a list of open tabs.

Where do I look to find the Qt Creator source code? I'm worried that I'll get buried in all kinds of other things going on that I won't be able to isolate the mouseover feature(s).

ChrisW67
28th April 2012, 05:34
I see, that's in 4.8 and I am only on 4.7.4. You could look in the Qt Assistant source which is probably a bit less convoluted than the Qt Creator source.

The magic happens in tools/assistant/tools/assistant/openpageswidget.cpp (http://qt.gitorious.org/qt/qt/blobs/4.8/tools/assistant/tools/assistant/openpageswidget.cpp) with the OpenPagesDelegate attached to the view and the OpenPagesWidget::handleClicked(), handlePressed() and possibly some other bits.

This particular functionality was backported from Qt Creator anyway.

russdot
28th April 2012, 22:29
Ah yes, sorry I should have mentioned I was using version 4.8. Thanks for pointing me towards that source file! Hopefully I can make use of the techniques.