I solved my problem by simply doing the following:
ui->treeWidget->scrollToItem(item);
const QRect r
= ui
->treeWidget
->visualItemRect
(item
);
ui->treeWidget->horizontalScrollBar()->setValue(r.x());
ui->treeWidget->scrollToItem(item);
const QRect r = ui->treeWidget->visualItemRect(item);
ui->treeWidget->horizontalScrollBar()->setValue(r.x());
To copy to clipboard, switch view to plain text mode
Basically, I retrieve the horizontal position of the item within the viewport of the tree widget, then I adjust the horizontal scrollbar such that it aligns with the left of the item.
Thanks again Santosh for your time.
Franz
Bookmarks