Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-interest Archive, November 2006
AW: QTableView - sectionClicked - sortByColumn [4.1.4]


Message 1 in thread

-> QObject::connect( itemTable, SIGNAL( sectionClicked( int ) ), SLOT( sortByColumn( int ) ) );
That connect fails (returns false) ...

When dubugging I found out that the desired slot is indeed called, but just does not sort the column ...




/*!
  Sorts the model by the values in the given \a column.
 */
void QTableView::sortByColumn(int column)
{
    Q_D(QTableView);

    if (!d->model)
        return;
    bool ascending = (horizontalHeader()->sortIndicatorSection() == column
                      && horizontalHeader()->sortIndicatorOrder() == Qt::DescendingOrder);
    Qt::SortOrder order = ascending ? Qt::AscendingOrder : Qt::DescendingOrder;
    horizontalHeader()->setSortIndicator(column, order);
    d->model->sort(column, order);
}



 

-----Ursprüngliche Nachricht-----
Von: John Dean [mailto:deanjx@xxxxxxxxx] 
Gesendet: Donnerstag, 02. November 2006 13:05
An: Kaiser, Rene
Betreff: Re: QTableView - sectionClicked - sortByColumn [4.1.4]

Hi

The connect statement looks wrong to me

Try QObject::connect( itemTable, SIGNAL( sectionClicked( int ) ), SLOT( sortByColumn( int ) ) );

At 11:43 02/11/2006, you wrote:

>Goal: I want to sort a QTableView whenever the user clicks on a 
>column's header.
>
>Problem: I've tried it with
> 
>connect(itemTable->horizontalHeader(),SIGNAL(sectionClicked(int)),
>itemTable, SLOT(sortByColumn(int)));
>         but that didn't work. I read quite a few things e.g.
> 
><http://www.qtcentre.org/forum/archive/index.php/t-467.html>http://www.
>qtcentre.org/forum/archive/index.php/t-467.html
> 
>http://www.qtforum.de/forum/viewtopic.php?p=10946&sid=24d1e9342d433549690e362ac02176bf
>         about it which said (at least my conclusio) that this  is/has 
>been a Qt-internal bug/issue.
>
>Does anybody know in which Qt version this matter will be solved?
>Is there another "affordable" way to do it?
>
>
>Thanks for your answers,
>r.
>
>
>--------------------------------------------------------------------
>   Rene Kaiser
>   Institute of Information Systems & Information Management
>   JOANNEUM RESEARCH Forschungsgesellschaft mbH
>   Steyrergasse 17, A-8010 Graz, AUSTRIA
>
>   phone:  +43-316-876-1173                   fax: +43-316-876-1191
>   web:    <http://www.joanneum.at/iis>http://www.joanneum.at/iis
>   e-mail: 
><mailto:rene.kaiser@xxxxxxxxxxx>mailto:rene.kaiser@xxxxxxxxxxx
>--------------------------------------------------------------------

--
 [ signature omitted ]