久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<tfoot id='6phcu'></tfoot>

<small id='6phcu'></small><noframes id='6phcu'>

    <bdo id='6phcu'></bdo><ul id='6phcu'></ul>

    1. <legend id='6phcu'><style id='6phcu'><dir id='6phcu'><q id='6phcu'></q></dir></style></legend>
    2. <i id='6phcu'><tr id='6phcu'><dt id='6phcu'><q id='6phcu'><span id='6phcu'><b id='6phcu'><form id='6phcu'><ins id='6phcu'></ins><ul id='6phcu'></ul><sub id='6phcu'></sub></form><legend id='6phcu'></legend><bdo id='6phcu'><pre id='6phcu'><center id='6phcu'></center></pre></bdo></b><th id='6phcu'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='6phcu'><tfoot id='6phcu'></tfoot><dl id='6phcu'><fieldset id='6phcu'></fieldset></dl></div>

      PyQt 對齊復選框并將其放在每一行

      PyQt allign checkbox and put it in every row(PyQt 對齊復選框并將其放在每一行)
    3. <legend id='VJHTd'><style id='VJHTd'><dir id='VJHTd'><q id='VJHTd'></q></dir></style></legend>
        <bdo id='VJHTd'></bdo><ul id='VJHTd'></ul>
          <tbody id='VJHTd'></tbody>
        <i id='VJHTd'><tr id='VJHTd'><dt id='VJHTd'><q id='VJHTd'><span id='VJHTd'><b id='VJHTd'><form id='VJHTd'><ins id='VJHTd'></ins><ul id='VJHTd'></ul><sub id='VJHTd'></sub></form><legend id='VJHTd'></legend><bdo id='VJHTd'><pre id='VJHTd'><center id='VJHTd'></center></pre></bdo></b><th id='VJHTd'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='VJHTd'><tfoot id='VJHTd'></tfoot><dl id='VJHTd'><fieldset id='VJHTd'></fieldset></dl></div>

            1. <small id='VJHTd'></small><noframes id='VJHTd'>

              <tfoot id='VJHTd'></tfoot>

                本文介紹了PyQt 對齊復選框并將其放在每一行的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我正在嘗試這個 使用復選框.遺憾的是,它是為 C++ 制作的,對 Python 代碼的任何改編都會導致此錯誤:'QWidget' object is not callable我想做的是在每一行添加一個復選框,這是我的代碼:

                I'm trying to do this with the check-box. Sadly is made for C++ and any adaptation of the code for Python has the result this error: 'QWidget' object is not callable What I wanna to do is to add a check-box on each row, this is my code:

                    pWidget = QWidget()
                    pCheckbox = QCheckBox()
                    pLayout = QVBoxLayout()
                    pLayout.addWidget(pCheckbox)
                    pLayout.setAlignment(Qt.AlignCenter)
                    pLayout.setContentsMargins(0, 0 ,0, 0)
                    pWidget.setLayout(pLayout)
                
                    for char in accounts:
                        for columnNumber in range(numberColumns):
                            chkBoxItem = QTableWidgetItem()
                            chkBoxItem.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
                            chkBoxItem.setCheckState(Qt.Unchecked)
                            self.mainAccountTable.insertRow(currentRowCount)
                            self.mainAccountTable.setItem(currentRowCount, 0, pWidget(chkBoxItem))
                            self.mainAccountTable.setItem(currentRowCount, 1, QTableWidgetItem(data[1]))
                

                如果我把 pLayout = Layout() 說它不是在 Python 中實現的.那么,我怎樣才能添加在中心對齊的復選框,而不是每行附近的文本區域?提前感謝您的任何提示.

                If I put pLayout = Layout() is saying that it isn't implemented in Python. So, how I can I add that checkbox aligned in center without the text area near for each row? Thanks in advance for any tips.

                稍后在循環內移動代碼是有效的,但我無法控制檢查:

                Later moving the code inside the loop is working , but I can't control the checks:

                for char in accounts:
                        for columnNumber in range(numberColumns):
                            pWidget = QWidget()
                            pCheckbox = QCheckBox()
                            pLayout = QVBoxLayout(pWidget)
                            pLayout.addWidget(pCheckbox)
                            pLayout.setAlignment(Qt.AlignCenter)
                            pLayout.setContentsMargins(0, 0 ,0, 0)
                            pWidget.setLayout(pLayout)
                            #chkBoxItem = QTableWidgetItem()
                            #chkBoxItem.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
                            #chkBoxItem.setCheckState(Qt.Unchecked)
                            self.mainAccountTable.insertRow(currentRowCount)
                            self.mainAccountTable.setCellWidget(currentRowCount, 0, pWidget)
                

                這是一個屏幕截圖我怎么知道我檢查了什么并建立了集合列表?

                This is a screenshoot How can I know what I checked and build set list?

                推薦答案

                這里是 ekhumoro 的示例被點擊時被檢查:

                Here is an example from ekhumoro to find what is checked when it s being clicked :

                from PyQt4 import QtGui, QtCore
                
                class Window(QtGui.QWidget):
                    def __init__(self, rows, columns):
                        QtGui.QWidget.__init__(self)
                        self.table = QtGui.QTableWidget(rows, columns, self)
                        for column in range(columns):
                            for row in range(rows):
                                item = QtGui.QTableWidgetItem('Text%d' % row)
                                if row % 2:
                                    item.setFlags(QtCore.Qt.ItemIsUserCheckable |
                                                  QtCore.Qt.ItemIsEnabled)
                                    item.setCheckState(QtCore.Qt.Unchecked)
                                self.table.setItem(row, column, item)
                        self.table.itemClicked.connect(self.handleItemClicked)
                        layout = QtGui.QVBoxLayout(self)
                        layout.addWidget(self.table)
                        self._list = []
                
                    def handleItemClicked(self, item):
                        if item.checkState() == QtCore.Qt.Checked:
                            print('"%s" Checked' % item.text())
                            self._list.append(item.row())
                            print(self._list)
                        else:
                            print('"%s" Clicked' % item.text())
                
                if __name__ == '__main__':
                
                    import sys
                    app = QtGui.QApplication(sys.argv)
                    window = Window(6, 3)
                    window.resize(350, 300)
                    window.show()
                    sys.exit(app.exec_())
                

                但您也可以迭代您的行并在正確的列上使用 .findChild(type(QtGui.QCheckBox())).isChecked()

                But you can also iterate on your rows and use .findChild(type(QtGui.QCheckBox())).isChecked() on the proper column

                如:

                from PyQt4 import QtGui, QtCore
                from PyQt4.QtCore import Qt
                
                class Window(QtGui.QWidget):
                    def __init__(self, rows, columns):
                        QtGui.QWidget.__init__(self)
                        self.table = QtGui.QTableWidget(rows, columns, self)
                        for row in range(rows):
                            qwidget = QtGui.QWidget()
                            checkbox = QtGui.QCheckBox()
                            checkbox.setCheckState(QtCore.Qt.Unchecked)
                            qhboxlayout = QtGui.QHBoxLayout(qwidget)
                            qhboxlayout.addWidget(checkbox)
                            qhboxlayout.setAlignment(Qt.AlignCenter)
                            qhboxlayout.setContentsMargins(0, 0, 0, 0)
                            self.table.setCellWidget(row, 0, qwidget)
                            self.table.setItem(row, 1, QtGui.QTableWidgetItem(str(row)))
                        layout = QtGui.QVBoxLayout(self)
                        self.button = QtGui.QPushButton()
                        self.button.setObjectName("loadButton")
                        layout.addWidget(self.table)
                        layout.addWidget(self.button)
                        self.button.clicked.connect(self.ButtonClicked)
                
                    def ButtonClicked(self):
                        checked_list = []
                        for i in range(self.table.rowCount()):
                            if self.table.cellWidget(i, 0).findChild(type(QtGui.QCheckBox())).isChecked():
                                checked_list.append(self.table.item(i, 1).text())
                        print checked_list
                
                
                if __name__ == '__main__':
                
                    import sys
                    app = QtGui.QApplication(sys.argv)
                    window = Window(3, 2)
                    window.resize(350, 300)
                    window.show()
                    sys.exit(app.exec_())
                

                這篇關于PyQt 對齊復選框并將其放在每一行的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                How to bind a function to an Action from Qt menubar?(如何將函數綁定到 Qt 菜單欄中的操作?)
                PyQt progress jumps to 100% after it starts(PyQt 啟動后進度躍升至 100%)
                How to set yaxis tick label in a fixed position so that when i scroll left or right the yaxis tick label should be visible?(如何將 yaxis 刻度標簽設置在固定位置,以便當我向左或向右滾動時,yaxis 刻度標簽應該可見
                `QImage` constructor has unknown keyword `data`(`QImage` 構造函數有未知關鍵字 `data`)
                Change x-axis ticks to custom strings(將 x 軸刻度更改為自定義字符串)
                How to show progress bar while saving file to excel in python?(如何在python中將文件保存為excel時顯示進度條?)
                <tfoot id='fEiKL'></tfoot>
                    <i id='fEiKL'><tr id='fEiKL'><dt id='fEiKL'><q id='fEiKL'><span id='fEiKL'><b id='fEiKL'><form id='fEiKL'><ins id='fEiKL'></ins><ul id='fEiKL'></ul><sub id='fEiKL'></sub></form><legend id='fEiKL'></legend><bdo id='fEiKL'><pre id='fEiKL'><center id='fEiKL'></center></pre></bdo></b><th id='fEiKL'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='fEiKL'><tfoot id='fEiKL'></tfoot><dl id='fEiKL'><fieldset id='fEiKL'></fieldset></dl></div>
                    • <bdo id='fEiKL'></bdo><ul id='fEiKL'></ul>
                        <tbody id='fEiKL'></tbody>

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

                      1. <legend id='fEiKL'><style id='fEiKL'><dir id='fEiKL'><q id='fEiKL'></q></dir></style></legend>

                          主站蜘蛛池模板: 亚洲国产高清免费 | 久久里面有精品 | 久久精品1| 亚洲精品大全 | 欧美日本一区 | 国产97视频在线观看 | 成人欧美在线 | 国产伦一区二区三区 | av毛片 | 日韩在线| 天天天操操操 | 亚洲一区影院 | 一级黄色绿像片 | 国产成人精品一区二区三区网站观看 | 一区二区三区视频在线 | 国产精品久久久久久久岛一牛影视 | 男人天堂av网站 | 国产一区亚洲 | 亚洲一区二区中文字幕 | 欧美日韩中文字幕 | 国产黄色大片在线免费观看 | 亚洲精品www久久久久久广东 | 亚洲欧美一区二区三区情侣bbw | 美女一区| 国产一区二区三区在线 | 国产一级片免费看 | 国产福利在线免费观看 | 午夜影视免费片在线观看 | 免费看a| 天天干狠狠干 | 午夜精品在线 | 国家aaa的一级看片 h片在线看 | 精品欧美一区二区三区久久久 | av黄色在线 | 天堂一区二区三区 | 国产精品国产精品国产专区不片 | 国产成人精品a视频一区www | 黄色在线播放视频 | 亚洲国产成人av好男人在线观看 | 国产成人综合在线 | 美女在线视频一区二区三区 |