
Originally Posted by
jpn
QTreeView seems to store that information as a private member before it calls drawRow() from drawTree(). There is no way for you to access that private member unless you include a private header (which might not be available on all environments so you might not want to do that)...
Just wondered if there was something which I was missing; so the thread.

Originally Posted by
jpn
But one question: why do you need a custom drawRow()?
- Always draw branches on the first *visible* column
- Always have the first visible column span all columns if it has child rows
Actually I just had to copy code from QTreeView::drawRow() and change it by about 20%. Apart from alternate background, there are two more places where I need the data stored in private pointer; while one of them I can certainly live without, following is the one I'm not sure of
// when the row contains an index widget which has focus,
// we want to paint the entire row as active
bool indexWidgetHasFocus = false;
if ((current.row() == index.row()) && !d->editors.isEmpty()) {
const int r = index.row();
for (int c = 0; c < header->count(); ++c) {
if (QWidget *editor
= indexWidget
(idx
)) { if (ancestorOf(editor, fw)) {
indexWidgetHasFocus = true;
break;
}
}
}
}
// when the row contains an index widget which has focus,
// we want to paint the entire row as active
bool indexWidgetHasFocus = false;
if ((current.row() == index.row()) && !d->editors.isEmpty()) {
const int r = index.row();
QWidget *fw = QApplication::focusWidget();
for (int c = 0; c < header->count(); ++c) {
QModelIndex idx = d->model->index(r, c, parent);
if (QWidget *editor = indexWidget(idx)) {
if (ancestorOf(editor, fw)) {
indexWidgetHasFocus = true;
break;
}
}
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks