connect(horizontalHeader(), SIGNAL(sectionClicked(int)), this, SLOT(onHeaderClicked(int)));
refer to http://developer.qt.nokia.com/faq/answer/how_can_i_sort_the_items_in_a_qtablewidget_on_multiple_columns
https://bbs.csdn.net/topics/360139821