The solution is far more easier than I thought (tested under Qt 3.3.5 on PLD Linux):
Qt Code:
  1. #include <qapplication.h>
  2. #include <qheader.h>
  3. #include <qlistview.h>
  4. #include <qpushbutton.h>
  5. #include <qvbox.h>
  6.  
  7. class Test : public QVBox
  8. {
  9. Q_OBJECT
  10. public:
  11. Test() : idx( 2 )
  12. {
  13. _lv = new QListView( this );
  14. _lv->addColumn( "A" );
  15. _lv->addColumn( "B" );
  16. _lv->addColumn( "C" );
  17.  
  18. new QListViewItem( _lv, "a1", "b1", "c1" );
  19. new QListViewItem( _lv, "a2", "b2", "c2" );
  20. new QListViewItem( _lv, "a3", "b3", "c3" );
  21.  
  22. QPushButton *pb = new QPushButton( "Switch", this );
  23. connect( pb, SIGNAL( clicked() ), this, SLOT( switchColumns() ) );
  24. }
  25.  
  26. private slots:
  27. void switchColumns()
  28. {
  29. _lv->header()->moveSection( 0, idx );
  30. _lv->triggerUpdate();
  31. _lv->header()->update();
  32.  
  33. idx = 2 - idx;
  34. }
  35.  
  36. private:
  37. QListView *_lv;
  38. int idx;
  39. };
  40.  
  41. int main( int argc, char **argv )
  42. {
  43. QApplication app( argc, argv );
  44.  
  45. Test mw;
  46.  
  47. app.setMainWidget( &mw );
  48. mw.show();
  49.  
  50. return app.exec();
  51. }
  52.  
  53. #include "main.moc"
To copy to clipboard, switch view to plain text mode