예제 #1
0
    box = QtWidgets.QGroupBox()
    box.setFlat(True)
    box.setTitle("Options")

    layout2 = QtWidgets.QVBoxLayout()
    box.setLayout(layout2)
    layout2.addWidget(QtWidgets.QRadioButton("Herring"))
    layout2.addWidget(QtWidgets.QRadioButton("Blue Parrot"))
    layout2.addWidget(QtWidgets.QRadioButton("Petunias"))
    layout2.addStretch()

    boxProxy = QtWidgets.QGraphicsProxyWidget()
    boxProxy.setWidget(box)

    # Parent widget.
    widget = QtWidgets.QGraphicsWidget()
    layout = QtWidgets.QGraphicsLinearLayout(QtCore.Qt.Vertical, widget)
    layout.addItem(editProxy)
    layout.addItem(buttonProxy)
    widget.setLayout(layout)

    p1 = Pixmap(QtGui.QPixmap(':/digikam.png'))
    p2 = Pixmap(QtGui.QPixmap(':/akregator.png'))
    p3 = Pixmap(QtGui.QPixmap(':/accessories-dictionary.png'))
    p4 = Pixmap(QtGui.QPixmap(':/k3b.png'))
    p5 = Pixmap(QtGui.QPixmap(':/help-browser.png'))
    p6 = Pixmap(QtGui.QPixmap(':/kchart.png'))

    scene = QtWidgets.QGraphicsScene(0, 0, 400, 300)
    scene.setBackgroundBrush(scene.palette().window())
    scene.addItem(widget)
예제 #2
0
    minSize = QtCore.QSizeF(30, 100)
    prefSize = QtCore.QSizeF(210, 100)
    maxSize = QtCore.QSizeF(300, 100)

    a = createItem(minSize, prefSize, maxSize, "A")
    b = createItem(minSize, prefSize, maxSize, "B")
    c = createItem(minSize, prefSize, maxSize, "C")
    d = createItem(minSize, prefSize, maxSize, "D")
    e = createItem(minSize, prefSize, maxSize, "E")
    f = createItem(QtCore.QSizeF(30, 50), QtCore.QSizeF(150, 50), maxSize, "F")
    g = createItem(QtCore.QSizeF(30, 50), QtCore.QSizeF(30, 100), maxSize, "G")

    l = QtWidgets.QGraphicsAnchorLayout()
    l.setSpacing(0)

    w = QtWidgets.QGraphicsWidget(None, QtCore.Qt.Window)
    w.setPos(20, 20)
    w.setLayout(l)

    # Vertical.
    l.addAnchor(a, QtCore.Qt.AnchorTop, l, QtCore.Qt.AnchorTop)
    l.addAnchor(b, QtCore.Qt.AnchorTop, l, QtCore.Qt.AnchorTop)

    l.addAnchor(c, QtCore.Qt.AnchorTop, a, QtCore.Qt.AnchorBottom)
    l.addAnchor(c, QtCore.Qt.AnchorTop, b, QtCore.Qt.AnchorBottom)
    l.addAnchor(c, QtCore.Qt.AnchorBottom, d, QtCore.Qt.AnchorTop)
    l.addAnchor(c, QtCore.Qt.AnchorBottom, e, QtCore.Qt.AnchorTop)

    l.addAnchor(d, QtCore.Qt.AnchorBottom, l, QtCore.Qt.AnchorBottom)
    l.addAnchor(e, QtCore.Qt.AnchorBottom, l, QtCore.Qt.AnchorBottom)