当前位置: 首页>>代码示例>>Python>>正文


Python QTableView.setVerticalHeader方法代码示例

本文整理汇总了Python中PyQt5.QtWidgets.QTableView.setVerticalHeader方法的典型用法代码示例。如果您正苦于以下问题:Python QTableView.setVerticalHeader方法的具体用法?Python QTableView.setVerticalHeader怎么用?Python QTableView.setVerticalHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtWidgets.QTableView的用法示例。


在下文中一共展示了QTableView.setVerticalHeader方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TableWindow

# 需要导入模块: from PyQt5.QtWidgets import QTableView [as 别名]
# 或者: from PyQt5.QtWidgets.QTableView import setVerticalHeader [as 别名]
class TableWindow(QMainWindow):
    def __init__(self, title):
        super(TableWindow, self).__init__()

        # Set up the user interface from Designer.
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.setWindowTitle(title)

        self.layout = QHBoxLayout(self.ui.centralwidget)
        self.ui.windowTitle = title
        self.ui.centralwidget.setLayout(self.layout)
        self.tableView = QTableView()
        self.layout.addWidget(self.tableView)
        self.tableView.setHorizontalHeader(MyHeaderView(Qt.Horizontal))
        self.tableView.setVerticalHeader(MyHeaderView(Qt.Vertical))

    def setModel(self, model):
        self.tableView.setModel(model)
        margins = self.layout.contentsMargins()
        self.resize((
            margins.left() + margins.right() + self.tableView.frameWidth() * 2 + self.tableView.verticalHeader().width() + self.tableView.horizontalHeader().length()),
            self.height())
开发者ID:cpsmv,项目名称:ecu,代码行数:25,代码来源:TablePrototype.py

示例2: Universe

# 需要导入模块: from PyQt5.QtWidgets import QTableView [as 别名]
# 或者: from PyQt5.QtWidgets.QTableView import setVerticalHeader [as 别名]
class Universe(QGroupBox):
    """
    Handle Universe and display its attributes
    Only one is created and display universe_selected attributes
    """
    def __init__(self, parent):
        super(Universe, self).__init__()
        # make it available for the whole instance
        self.ola = parent.ola
        # intialize variable used in ola_connect method
        self.old = None
        self.universe_selected = None
        # Create universe attributes
        self.create_attributes()
        # Create the view to display values
        self.create_tableview()
        # Add the previous UI stuffs to a layout
        grid = self.create_layout()
        self.grid = grid
        self.setLayout(grid)
        parent.vbox.addWidget(self)
        self.parent = parent

    def create_attributes(self):
        """
        create attributes widget for the universe
        """
        self.id = QSpinBox()
        self.id.setReadOnly(True)
        self.id.setRange(0, 65536)
        self.name = QLineEdit()
        self.name.textEdited.connect(self.edit_name)
        self.name.setFixedWidth(200)
        self.merge_mode_label = QLabel('Merge Mode')
        self.merge_mode_htp_label = QLabel('HTP')
        self.merge_mode_htp = QRadioButton()
        self.merge_mode_ltp_label = QLabel('LTP')
        self.merge_mode_ltp = QRadioButton()
        self.merge_mode_ltp.toggled.connect(self.edit_merge_mode_ltp)
        self.merge_mode_htp.toggled.connect(self.edit_merge_mode_htp)

    def edit_name(self, name):
        if self.universe_selected:
            if self.ola.client.SetUniverseName(self.universe_selected.id, name):
                self.parent.universes_refresh()
            else:
                self.parent.status("name edit failed")
                if debug:
                    "edit universe name failed"

    def edit_merge_mode_htp(self, state):
        if state:
            if debug:
                print('switch universe to HTP merge mode')
            self.edit_merge_mode(1)

    def edit_merge_mode_ltp(self, state):
        if state:
            if debug:
                print('switch universe to LTP merge mode')
            self.edit_merge_mode(2)

    def edit_merge_mode(self, merge_mode):
        if self.universe_selected:
            if self.ola.client.SetUniverseMergeMode(self.universe_selected.id, merge_mode):
                self.parent.universes_refresh()
            else:
                self.parent.status("merge mode edit failed")
                if debug:
                    "edit universe merge mode failed"

    def create_tableview(self):
        """
        create the table view for DMX values
        """
        self.view = QTableView()
        self.view.setSelectionMode(QAbstractItemView.NoSelection)
        self.model = UniverseModel(self)
        self.view.setModel(self.model)
        # set up headers of the QTableView
        v_headers = QHeaderView(Qt.Vertical)
        self.view.setVerticalHeader(v_headers)
        h_headers = QHeaderView(Qt.Horizontal)
        self.view.setHorizontalHeader(h_headers)
        if debug :
            print('how many lines : ', v_headers.count())
            print('how many columns : ', h_headers.count())
        # set up rows and columns
        for col in range(self.model.columnCount()):
            self.view.setColumnWidth(col, 28)
        for row in range(self.model.rowCount()):
            self.view.setRowHeight(row, 20)
        self.view.setMinimumHeight(350)

    def create_layout(self):
        """
        create the layout for the universe display
        """
        grid = QGridLayout()
        grid.addWidget(self.id, 0, 0, 1, 1)
#.........这里部分代码省略.........
开发者ID:PixelStereo,项目名称:ola-pyqt-gui,代码行数:103,代码来源:universe.py


注:本文中的PyQt5.QtWidgets.QTableView.setVerticalHeader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。