문제

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 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);
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top