Thank you very much! it works!
Code in the main programm :
QHeaderView *tmpHeaderView
= tableView
->horizontalHeader
();
tmpHeaderView->setClickable(true);
tableView->setSortingEnabled(true);
QHeaderView *tmpHeaderView = tableView->horizontalHeader();
tmpHeaderView->setClickable(true);
tableView->setSortingEnabled(true);
To copy to clipboard, switch view to plain text mode
Code in the class inherited form QTableView :
void DSTableView::setSortingEnabled(bool _enable)
{
horizontalHeader()->setSortIndicatorShown(_enable);
if (_enable)
{
disconnect(horizontalHeader(), SIGNAL(sectionPressed(int)),
this, SLOT(selectColumn(int)));
connect(horizontalHeader(), SIGNAL(sectionClicked(int)),
this, SLOT(sortByColumn(int)));
sortByColumn(horizontalHeader()->sortIndicatorSection());
}
else
{
connect(horizontalHeader(), SIGNAL(sectionPressed(int)),
this, SLOT(selectColumn(int)));
disconnect(horizontalHeader(), SIGNAL(sectionClicked(int)),
this, SLOT(sortByColumn(int)));
}
}
void DSTableView::setSortingEnabled(bool _enable)
{
horizontalHeader()->setSortIndicatorShown(_enable);
if (_enable)
{
disconnect(horizontalHeader(), SIGNAL(sectionPressed(int)),
this, SLOT(selectColumn(int)));
connect(horizontalHeader(), SIGNAL(sectionClicked(int)),
this, SLOT(sortByColumn(int)));
sortByColumn(horizontalHeader()->sortIndicatorSection());
}
else
{
connect(horizontalHeader(), SIGNAL(sectionPressed(int)),
this, SLOT(selectColumn(int)));
disconnect(horizontalHeader(), SIGNAL(sectionClicked(int)),
this, SLOT(sortByColumn(int)));
}
}
To copy to clipboard, switch view to plain text mode
Thank you very much!
Xelag
Bookmarks