-1

How can i make a GUI App like this without using QT Designer:

Image http://imagizer.imageshack.us/v2/800x600q90/856/zz53.png

1
  • 1
    +1 for the awesome red text, -2 for showing absolutely no indication of doing any work to answer the question. Net change: -1.
    – eric
    Jul 14, 2014 at 0:29

1 Answer 1

2

The answer to this question should really be: by reading the finely-crafted manual.

One of the best things about Qt is its superb documentation. It's so good, that you don't even need to know C++ to be able to use it. You're really missing out on an important part of learning PyQt/PySide if you don't famialize yourself with everything it has to offer.

But what the heck, here's a crude mock-up of what you asked for (the rest I'll leave to you as an exercise):

from PySide import QtCore, QtGui

class Window(QtGui.QMainWindow):
    def __init__(self):
        super(Window, self).__init__()
        grid = QtGui.QGridLayout()
        grid.addWidget(QtGui.QLabel('Label A', self), 0, 0)
        grid.addWidget(QtGui.QLabel('Label B', self), 0, 1)
        grid.addWidget(QtGui.QLabel('Label C', self), 1, 0)
        grid.addWidget(QtGui.QLabel('Label D', self), 1, 1)
        vbox = QtGui.QVBoxLayout()
        vbox.addWidget(QtGui.QRadioButton('Radio A', self))
        vbox.addWidget(QtGui.QRadioButton('Radio B', self))
        vbox.addWidget(QtGui.QRadioButton('Radio C', self))
        vbox.addWidget(QtGui.QPushButton('Button', self))
        widget = QtGui.QWidget(self)
        layout = QtGui.QGridLayout(widget)
        layout.addLayout(grid, 0, 0)
        layout.addLayout(vbox, 0, 1)
        layout.addWidget(
            QtGui.QSlider(QtCore.Qt.Horizontal, self), 1, 0, 1, 2)
        self.setCentralWidget(widget)

if __name__ == '__main__':

    import sys
    app = QtGui.QApplication(sys.argv)
    window = Window()
    window.setGeometry(500, 300, 100, 100)
    window.show()
    sys.exit(app.exec_())
2
  • Thanks again @ekhumoro, i just tried what you wrote above here, and it works perfectly, this is the real code, omitting some other implements: codepad.org/CoppVOAE if you want to give a look.. Anyway you can also try it out, cus i'd like to display the radiobuttons in the top of the VBoxLayout, and not right in the middle of it. When i got some free time, i'll try to give a look to the guide you posted before, thanks again for answering me! Jan 30, 2014 at 22:38
  • I wish documentation was good for less basic stuff. Working in c++ is big plus if you really want to take full advantage of documentation for qt that is online. I guarantee at some point you will end up at the C++ documentation, and find it has no equivalent in PySide/PyQt.
    – eric
    Jul 14, 2014 at 0:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.