QListWidget set item spacing dynamically based on font's height
I would like to set item spacing based on QListWidget's font's size. How can I do that ?
Re: QListWidget set item spacing dynamically based on font's height
solved by subclassing QItemDelegate and overriding sizehint- function:
.cpp
Code:
#include "mylistdelegate.h"
#include <QDebug>
MyListDelegate
::MyListDelegate(QObject *parent
) :{
}
{
sz.setHeight(fm.height()*1.5);
return sz;
}
.h
Code:
#include <QStyledItemDelegate>
#include <QItemDelegate>
{
Q_OBJECT
public:
explicit MyListDelegate
(QObject *parent
= 0);
};