示例#1
0
if __name__ == '__main__':
    app = QApplication(sys.argv)

    model = QStandardItemModel(1, 1)
    model.setHeaderData(0, Qt.Horizontal, "Task")

    ## A view with some alternative header labels
    view1 = View()
    grid1 = DateTimeGrid()
    #grid1.setUserDefinedUpperScale(DateTimeScaleFormatter(DateTimeScaleFormatter.Year, "yyyy", "In the year %1.", Qt.AlignLeft))
    #grid1.setUserDefinedLowerScale(DateTimeScaleFormatter(DateTimeScaleFormatter.Month, "MMMM", "In the month %1.", Qt.AlignRight))
    grid1.setScale(DateTimeGrid.ScaleUserDefined)
    grid1.setDayWidth(6.0)
    view1.setGrid(grid1)
    view1.setModel(model)
    view1.show()

    ## A view with header and vertical grid lines for every 10 minutes
    view2 = View()
    tw = view2.leftView()
    h = MyHeaderView()
    tw.setHeader(h)
    grid2 = DateTimeGrid()
    grid2.setDayWidth(5000)
    grid2.setUserDefinedUpperScale(
        DateTimeScaleFormatter(DateTimeScaleFormatter.Hour, "hh"))
    grid2.setUserDefinedLowerScale(MyDateTimeScaleFormatter())
    grid2.setScale(DateTimeGrid.ScaleUserDefined)
    view2.setGrid(grid2)
    view2.setModel(model)
    view2.show()
示例#2
0
文件: main.py 项目: zdrgbsky/KDChart
            return

        if from_ >= len(self.m_tasks) or to >= len(self.m_tasks) + 1:
            return

        if self.beginMoveRows(QModelIndex(), from_, from_, QModelIndex(), to):
            self.m_tasks.insert(to, self.m_tasks.pop(from_))
            self.endMoveRows()
        else:
            return


if __name__ == '__main__':
    app = QApplication(sys.argv)
    view = View()
    model = MyTaskModel()

    constraints = ConstraintModel()
    constraints.addConstraint(Constraint(model.index(0, 0), model.index(1, 0)))
    constraints.addConstraint(Constraint(model.index(0, 0), model.index(2, 0)))
    constraints.addConstraint(Constraint(model.index(1, 0), model.index(3, 0)))

    view.setModel(model)
    view.setConstraintModel(constraints)
    view.show()

    # After 5 seconds, move row 1 to pos 0: #
    QTimer.singleShot(5000, lambda: model.moveRow(1, 0))

    sys.exit(app.exec_())