[Interest] Tool tip for a QTableView column heading?

Carl Schumann schumann at fnal.gov
Thu Apr 26 15:53:40 CEST 2012


Qt community,

David, thanks that definitely seems to be heading in a promising direction.

It does create a challenge though.   The model that I am using for my 
QTableView inherits from QAbstractTableModel.   Your proposal appears to 
require that I change my model to instead inherit from 
QStandardItemModel, cotrrect?   It is this change of inheritance that 
appears to be creating issues with an existing call to 
<...Model>::index(int row,int column, const QModelIndex & parent = 
QModelndex() ) const in my existing code.

In my existing call I do not pass a parent argument and therefore use 
the default.   This worked fine when the call was ultimately to 
QAbstractTableModel::index(...) but appears to be returning an invalid 
index (-1,-1) when the call ends up calling 
QStandardItemModel::index(...).   I am certainly willing to pass an 
explicit parent argument, but am not sure how to generate a valid parent.

As always any help would be appreciated please.  Thanks again.

Sincerely,
Carl

On 4/25/2012 11:55 PM, David Boosalis wrote:
> Here is an example with a QTreeView, it should work for QTableView.
>
>
>  _model = new ModelItemModel(this);
>   setModel(_model);
>   for(int i=0;i<NumColumns;i++) {
>     headerItem[i] = new QStandardItem(headerLabel[i]);
>     _model->setHorizontalHeaderItem(i,headerItem[i]);
>     headerItem[i]->setToolTip(headerToolTips[i]);
>   }
>
> The above code is not complete, but I think you get the picture
>
> -David
>
> On Wed, Apr 25, 2012 at 2:38 PM, Carl Schumann <schumann at fnal.gov 
> <mailto:schumann at fnal.gov>> wrote:
>
>     Qt community,
>
>     I would like to add tool tips to the column headings of a QTableView
>     instance.   Is there a way to do this please?   I see that I can get a
>     QHeaderView and add a tool tip to it but that would be for the
>     whole set
>     of headings not one tool tip for each heading, if I understand things
>     correctly.    Thanks for any help please.
>
>     Sincerely,
>     Carl Schumann
>     _______________________________________________
>     Interest mailing list
>     Interest at qt-project.org <mailto:Interest at qt-project.org>
>     http://lists.qt-project.org/mailman/listinfo/interest
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120426/f5376332/attachment.html>


More information about the Interest mailing list