I want a table cell with text aligned to the left and icon aligned to the right side.
But now, im getting both icon and text left aligned, here what i have tried
QtTableWidgetItem * item = new QtTableWidgetItem("program");
item -> setIcon(icon);
ui -> tableWidget -> setItem(i,j,item);
To manage the position of the icon and the text you must use a delegate, in this case I use the
QStyledItemDelegate
and I overwrite theinitStyleOption()
method:C++ version
aligndelegate.h
Then it is established in the delegate:
Python version: