you can add a widget to an item. So just create a for example frame that contains your icon and add it to the list item.
QListWidget *list = new QListWidget(this);
QFrame *custom = new QFrame;
//add whatever you need to the frame
QListWidgetItem *i = new QListWidgetItem;
I used this for a list where each item needed several buttons to get for example detailed information about the item or delete the item from the list with one click
Please have some patience, this forum is community driven and not all users live in the same timezone as you.
The picture you are linking to doesn't show a hovered button but a checked button. You will have that visual effect if you set the checkable property of the action to corresponding to the button as true and you check it.
After scouring the web, it appears that the only way to do this is the very complex technique of subclassing the widget. It's easier to just put another button on it, but then I had the problem where I couldn't pass a hover event to the QPushButton underneath it. This lead me to learn the technique on StackOverflow of building an eventFilter.
The thing is that toolbars don't really display icons. They display widgets (that can have icons). By default when you add an action to a toolbar a QToolButton is created for it, but you are not limited to that and can add any widget e.g. an expanding line edit, combobox or a button with an icon and text. All of these can have different size policies, be expanding or have a custom stylesheet applied.
All of this makes calculating such size not feasible because how would you calculate it if a widget can change its size.
What I'm saying is that yours is a special, very specific case (with just icons), and as such you need to handle it yourself if you want to.
To answer your questions:
It's not one thing that adds the space. There are couple of aspects that can contribute. You can control some(or all?) of them with stylesheets e.g. set padding of the toolbar and toolbuttons to 0 and margins and borders of the toolbuttons. By default all of these depend on a style and will vary across computers. You also need to be careful to consider the size of the toolbar handle (if it's movable) as its size depends on the active style. You also need to consider that if the icon is narrower than the iconSize then there's gonna by space left anyway.
nope, AFAIK it can vary from one item of the toolbar to another if you set it this way
nope and just out of curiosity - why do you need that? The bar will display an arrow button that will let you see the overflowing items. Also such calculated size would be useless as the window can be resized and thus the toolbar too (unless you're doing some really fancy layout).