Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我开发了一个提取列表元素的程序(QListView)。如何根据 QListView 的大小设置元素的大小?我在委托中编写了 sizeHint 的实现,但是我不知道从哪里获取实例 QListView 的大小。
解决方案:
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); }