• <i id='JNk6L'><tr id='JNk6L'><dt id='JNk6L'><q id='JNk6L'><span id='JNk6L'><b id='JNk6L'><form id='JNk6L'><ins id='JNk6L'></ins><ul id='JNk6L'></ul><sub id='JNk6L'></sub></form><legend id='JNk6L'></legend><bdo id='JNk6L'><pre id='JNk6L'><center id='JNk6L'></center></pre></bdo></b><th id='JNk6L'></th></span></q></dt></tr></i><div id='JNk6L'><tfoot id='JNk6L'></tfoot><dl id='JNk6L'><fieldset id='JNk6L'></fieldset></dl></div>
    1. <small id='JNk6L'></small><noframes id='JNk6L'>

      <legend id='JNk6L'><style id='JNk6L'><dir id='JNk6L'><q id='JNk6L'></q></dir></style></legend>

      1. <tfoot id='JNk6L'></tfoot>

          <bdo id='JNk6L'></bdo><ul id='JNk6L'></ul>

        如果选择了多个项目,如何在 QListWidget 中打印多

        时间:2023-08-04

        <small id='p52FG'></small><noframes id='p52FG'>

              <legend id='p52FG'><style id='p52FG'><dir id='p52FG'><q id='p52FG'></q></dir></style></legend>
            1. <tfoot id='p52FG'></tfoot>
                  <bdo id='p52FG'></bdo><ul id='p52FG'></ul>

                    <tbody id='p52FG'></tbody>

                  <i id='p52FG'><tr id='p52FG'><dt id='p52FG'><q id='p52FG'><span id='p52FG'><b id='p52FG'><form id='p52FG'><ins id='p52FG'></ins><ul id='p52FG'></ul><sub id='p52FG'></sub></form><legend id='p52FG'></legend><bdo id='p52FG'><pre id='p52FG'><center id='p52FG'></center></pre></bdo></b><th id='p52FG'></th></span></q></dt></tr></i><div id='p52FG'><tfoot id='p52FG'></tfoot><dl id='p52FG'><fieldset id='p52FG'></fieldset></dl></div>
                  本文介绍了如果选择了多个项目,如何在 QListWidget 中打印多个项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我有 QListWidget 并且那里有字符串,当我选择一个字符串时,我想显示它的索引号和文本.但问题是,如果我选择超过 1 个项目,它不会显示所有索引.它只显示一个.

                  I have QListWidget and there are strings there, when I select a string, I wanted to display the index number and text of that. But the problem is, if I select more than 1 items, it doesn't display all of the indexes. It displays only one.

                  from PyQt5.QtWidgets import *
                  import sys
                  
                  class Pencere(QWidget):
                      def __init__(self):
                          super().__init__()
                          self.layout = QVBoxLayout(self)
                  
                          self.listwidget = QListWidget(self)
                          self.listwidget.addItems(["Python","Ruby","Go","Perl"])
                          self.listwidget.setSelectionMode(QAbstractItemView.MultiSelection)
                  
                  
                          self.buton = QPushButton(self)
                          self.buton.setText("Ok")
                          self.buton.clicked.connect(self.but)
                  
                          self.layout.addWidget(self.listwidget)
                          self.layout.addWidget(self.buton)
                  
                      def but(self):
                          print (self.listwidget.currentRow()+1)
                  
                  
                  uygulama = QApplication(sys.argv)
                  pencere = Pencere()
                  pencere.show()
                  uygulama.exec_()
                  

                  如果我选择超过 1 个项目,如何显示所有项目名称和索引?

                  How can I display all of the items names and indexes if I select more than 1 items?

                  推荐答案

                  我用这个解决了

                  def but(self):
                      x = self.listwidget.selectedItems()
                      for y in x:
                          print (y.text())
                  

                  这篇关于如果选择了多个项目,如何在 QListWidget 中打印多个项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:PyQt5按钮未连接 下一篇:线程时出现 msgbox 错误,GUI 块

                  相关文章

                  最新文章

                  <i id='ibUla'><tr id='ibUla'><dt id='ibUla'><q id='ibUla'><span id='ibUla'><b id='ibUla'><form id='ibUla'><ins id='ibUla'></ins><ul id='ibUla'></ul><sub id='ibUla'></sub></form><legend id='ibUla'></legend><bdo id='ibUla'><pre id='ibUla'><center id='ibUla'></center></pre></bdo></b><th id='ibUla'></th></span></q></dt></tr></i><div id='ibUla'><tfoot id='ibUla'></tfoot><dl id='ibUla'><fieldset id='ibUla'></fieldset></dl></div>

                • <tfoot id='ibUla'></tfoot>
                  1. <legend id='ibUla'><style id='ibUla'><dir id='ibUla'><q id='ibUla'></q></dir></style></legend>

                      <small id='ibUla'></small><noframes id='ibUla'>

                      • <bdo id='ibUla'></bdo><ul id='ibUla'></ul>