开发者

Size of element depending on size of the QListView

开发者 https://www.devze.com 2023-01-17 13:39 出处:网络
I developing a program that draws in elements of the list (QListView). How do I set the size of an element depending on the size of the QListView?

I developing a program that draws in elements of the list (QListView). How do I set the size of an element depending on the size of the QListView? I write implementation of the sizeHint in the开发者_C百科 delegate, but where to get the size of the instance QListView I don't know.


Solution:

QSize SpinBoxDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex & index) const
{
    QStyleOptionViewItemV4 opt(option);

    qDebug("W = %d\n", opt.widget->width());
    qDebug("H = %d\n", opt.widget->height());
    return QSize(100, 100);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消