简体   繁体   中英

List of QLabel in PySide/Qt

I am a newbie with PySide. I have a QGridlayout with QLabel's and I want to add/remove/update QLabel.

  1. Is it possible to create QList of QLabel with PySide similar to Qt in C++? After I populate the QGridlayout with QLabel and I want to dynamically increase/decrease the number of items in QGridlayout.

  2. Is QListWidget/QListWidgetItem only way to create list in PySide? Can it be used with QLabel/QPixmap?

  1. Sure. The python code will look just like C++ would look, sans syntax adaptations.

  2. No. You can use a QStandardItemModel , or a custom model. In addition, there's no point to creating QLabel delegates for model data, since all standard views handle images and pixmaps available from Qt::DecorationRole . If all you want is a list of images, even a custom model would be trivial.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM