Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-81034

After jointing a range of cells horizontally, and then I joint the cells generally, the selected cells go mad

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P4: Low
    • None
    • 5.14.0
    • Widgets: Itemviews
    • None
    • Windows

    Description

      1. Select a range of cells and joint them horizontally.
      2. Select the jointed cells and joint them generally.
        from PySide2 import QtCore
        from PySide2 import QtGui
        from PySide2 import QtWidgets
        import PySide2
        import os
        import sys
        class MainWindow(QtWidgets.QMainWindow):
            def __init__(self, parent=None):
                super(MainWindow, self).__init__(parent=None)
                menuBar = self.menuBar()
                joint_cell_menu = QtWidgets.QMenu("Joint")
                joint_cell_action = QtWidgets.QAction("Joint Cells", joint_cell_menu)
                self.connect(joint_cell_action, QtCore.SIGNAL("triggered(bool)"), self.joint_cell)
                horizontal_joint_cell_action = QtWidgets.QAction("Joint Cells Horizontally", joint_cell_menu)
                self.connect(horizontal_joint_cell_action, QtCore.SIGNAL("triggered(bool)"), self.horizontal_joint_cell_action)             
                joint_cell_menu.addAction(joint_cell_action)
                joint_cell_menu.addAction(horizontal_joint_cell_action)
                menuBar.addMenu(joint_cell_menu)               
                self.view = View()               
                self.setCentralWidget(self.view)
            def joint_cell(self):
                indexes = self.view.excel.selectedIndexes()
                first_index = indexes[0]
                last_index = indexes[-1]        
                first_row = first_index.row()
                first_column = first_index.column()
                last_row = last_index.row()
                last_column = last_index.column()
                self.view.excel.setSpan(first_row, first_column, last_row-first_row+1, last_column-first_column+1)
            def horizontal_joint_cell_action(self):
                indexes = self.view.excel.selectedIndexes()        
                first_index = indexes[0]
                last_index = indexes[-1]        
                first_row = first_index.row()
                first_column = first_index.column()
                last_row = last_index.row()
                last_column = last_index.column()
                columns = last_column-first_column+1
                for r in range(first_row, last_row+1, 1):
                    self.view.excel.setSpan(r, first_column, 1, columns)
        class View(QtWidgets.QGraphicsView):
            def __init__(self, parent=None):
                super(View, self).__init__(parent=None)
                desktop = QtWidgets.QDesktopWidget()
                self.scene = Scene()        
                self.excel = TableWidget(10, 10)     
                self.setScene(self.scene)  
                p = self.scene.addWidget(self.excel)
                self.scene.setSceneRect(p.sceneBoundingRect().x(), p.sceneBoundingRect().y(), desktop.width(), desktop.height()+100)   
        class Scene(QtWidgets.QGraphicsScene):
            def __init__(self, parent=None):
                super(Scene, self).__init__(parent=None)
        class TableWidget(QtWidgets.QTableWidget):
            def __init__(self, rows, columns, parent=None):
                super(TableWidget, self).__init__(parent=None)
                self.setParent(parent)              
                self.setRowCount(rows)
                self.setColumnCount(columns)           
                self.resize(3000, 3000)def main():
            app = QtWidgets.QApplication([])
            mainwindow = MainWindow()
            mainwindow.show()
            sys.exit(app.exec_())
        if __name__ == "__main__":
            main()
        

       

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            nori Harunori Fujimoto
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes