c++ - How to disable whole column selection of QTableView? -


void setselectionbehavior ( qabstractitemview::selectionbehavior behavior )

this function accepts 1 of 3 values: selecting items, selecting rows , selecting cells.

question:

i need case when clicking cell, selected, when clicking row index, row selected when clicking column header whole column not selected. understand cant done using function.

i need tableview behave same when selectionbehavior::selectitems set.

but when user clicks on header column should not selected.

i thinking disabling column selection qheaderview can't find how?

from application:

    // header qtableview tableview (replace widget name)     qheaderview *header = new qheaderview(qt::horizontal, tableview); #if qt_version < 0x50000 // qt 4.8.1     header->setresizemode(qheaderview::resizetocontents); #else // qt 5.2.0     header->setsectionresizemode(qheaderview::resizetocontents); #endif     header->sethighlightsections(false); // want 

sethighlightsections(bool) slot valid qt 4 , qt 5

edit: excuse carelessness! works if use selectrows or selectitems singleselection. can find proof in sources qheaderview.cpp , qtableview.cpp, slots voidqheaderview::mousepressevent(qmouseevent *e); , voidqtableviewprivate::selectcolumn(int column, bool anchor);

for selectitems can used slot:

    header->setclickable(false); 

Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -