[Interest] Tool tip for a QTableView column heading?

Linos info at linos.es
Thu Apr 26 16:37:53 CEST 2012


Hi!,
	if you are already using a QAbstractTableModel subclass why are you not using
Qt::TooltipRole in headerData method of your model?

http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#headerData

Regards,
Miguel Angel.

El 26/04/12 15:53, Carl Schumann escribió:
> 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
>>
>>
> 
> 
> 
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest




More information about the Interest mailing list