当前位置:网站首页>Add widget on qlistwidgetitem
Add widget on qlistwidgetitem
2022-06-27 05:44:00 【opera321】
1、 additional widget No display
These two sentences cannot be reversed :
listWidget>addItem(newItem);
listWidget->setItemWidget(newItem, itemWidget);
2、 additional widget The position has shifted
QListWidget Dynamic increase item Under the way , by item Additional widget A position shift may occur .
The solution is to associate a delegate , This delegate does not need to be attached to widget It matters , Just reload updateEditorGeometry Function .
XItemDelegate.h
#ifndef XITEMDELEGATE_H
#define XITEMDELEGATE_H
#include <QStyledItemDelegate>
class XItemDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
explicit XItemDelegate(QWidget *parent = nullptr);
virtual void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;
signals:
public slots:
};
#endif // XITEMDELEGATE_H
XItemDelegate.cpp
#include "XItemDelegate.h"
XItemDelegate::XItemDelegate(QWidget *parent)
{
}
void XItemDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
editor->setGeometry(option.rect);
}
XItemDelegate* itemDelegate = new XItemDelegate();
listWidget->setItemDelegate(itemDelegate);
边栏推荐
- Senior [Software Test Engineer] learning route and necessary knowledge points
- Two position relay rxmvb2 r251 204 110dc
- [nips 2017] pointnet++: deep feature learning of point set in metric space
- EPICS记录参考5 -- 数组模拟输入记录Array Analog Input (aai)
- 【Cocos Creator 3.5.1】event.getButton()的使用
- How JQ gets the ID name of an element
- Unicast, multicast and broadcast of IP network communication
- Experience oceanbase database under win10
- Go日志-Uber开源库zap使用
- Epics record reference 5 -- array analog input recordarray analog input (AAI)
猜你喜欢

Zener diode zener diode sod123 package positive and negative distinction

树莓派4B上运行opcua协议DEMO接入kubeedge
![[FPGA] design and implementation of frequency division and doubling based on FPGA](/img/84/75d473d3d8e670260ba16d06705c2f.png)
[FPGA] design and implementation of frequency division and doubling based on FPGA

双位置继电器JDP-1440/DC110V

RTP 发送PS流工具(已经开源)

齐纳二极管 稳压二极管 SOD123封装 正负区分

高翔slam14讲-笔记1

双位置继电器XJLS-8G/220

Wechat applet websocket use case

关于元器件封装的一些文章和一下我的体会
随机推荐
体验 win10 下 oceanbase 数据库
Junda technology - centralized monitoring scheme for multi brand precision air conditioners
Avoid asteroids
项目-h5列表跳转详情,实现后退不刷新,修改数据则刷新的功能(记录滚动条)
思维的技术:如何破解工作生活中的两难冲突?
When STM32 turns off PWM output, it is a method to fix IO output at high or low level.
Interview: what are the positioning methods in selenium? Which one do you use most?
Mechanical transcoding journal [17] template, STL introduction
Cognition - how to fill in 2022 college entrance examination volunteers
STM32 MCU pin_ How to configure the pin of single chip microcomputer as pull-up input
jq怎么获取倒数的元素
LeetCode-515. 在每个树行中找最大值
Go日志-Uber开源库zap使用
【Cocos Creator 3.5.1】坐标的加法
Obtenir le volume du système à travers les plateformes de l'unit é
开门小例子学习十种用例图
30个单片机常见问题及解决办法!
认知篇----2022高考志愿该如何填报
QT using Valgrind to analyze memory leaks
Using domain name forwarding mqtt protocol, pit avoidance Guide