[Qt-interest] Colum Names form QTreeView

Rob Simmermon rob.simmermon at simmtechsolutions.com
Mon May 10 19:11:35 CEST 2010


I have figured out how to get the column headings, but now when I call  
"sizeHintForCOlumn" my program crashes.

here's my code:

     for(columnCounter=0;columnCounter<columnCount;columnCounter++)
     {
         // get column header and add to end of current line
          
lineToWrite.insert(insertPoint,tvTreeView->model()->headerData(columnCounter,  
Qt::Horizontal).toString());
          
insertPoint+=tvTreeView->header()->sizeHintForColumn(columnCounter) + 2;
     }


It crashes on the last line of the loop on the very first iteration.


Quoting Rob Simmermon <rob.simmermon at simmtechsolutions.com>:

> This shouldn't be this hard, but for the life of me can't figure out
> how to get the column heading titles from a QTreeView that is set with
> a model.
>
> I've tried:
>
> tvTreeView->model()->record().fieldName(columnCounter)
>
> Only to get:
>
> src/TreeWidgetUtilities.cpp:422: error: 'class QAbstractItemModel' has
> no member named 'record'
>
>
>
> Rob Simmermon
> 411 N. Blanche Ave.
> Madison, SD  57042
> E - rob.simmermon at simmtechsolutions.com
> T - (605) 868-9404
> F - (866) 260-2036
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>




Rob Simmermon
SIMMTECH Solutions
411 N. Blanche Ave.
Madison, SD  57042
http://www.simmtechsolutions.com
E - rob.simmermon at simmtechsolutions.com
T - (605) 868-9404
F - (866) 260-2036






More information about the Qt-interest-old mailing list