Problem with Qt

M

Michael McGarry

Hi,

I am trying to show a radio button group on a window, but only the last
radio button shows up. Anyone know why?

Here is the code:

from qt import *
import sys
a = QApplication(sys.argv)
widget = QWidget()
trafftype = QButtonGroup("Traffic Type", widget)
poisson = QRadioButton("Poisson", trafftype)
selfsimilar = QRadioButton("Self-Similar", trafftype)
a.setMainWidget(widget)
widget.show()
a.exec_loop()

Any help is greatly appreciated.

Michael
 
D

Diez B. Roggisch

I think you have to introduce a layout on the group. The best thing is to
use qdesigner, it will do that for you. If you really need code, this is
cut'n'paste from a generate py-file:

self.buttonGroup4 = QButtonGroup(self,"buttonGroup4")
self.buttonGroup4.setColumnLayout(0,Qt.Vertical)
self.buttonGroup4.layout().setSpacing(6)
self.buttonGroup4.layout().setMargin(11)
buttonGroup4Layout = QHBoxLayout(self.buttonGroup4.layout())
buttonGroup4Layout.setAlignment(Qt.AlignTop)

self.radioButton3 = QRadioButton(self.buttonGroup4,"radioButton3")
buttonGroup4Layout.addWidget(self.radioButton3)
self.radioButton3_2 = QRadioButton(self.buttonGroup4,"radioButton3_2")
buttonGroup4Layout.addWidget(self.radioButton3_2)
 
M

Michael McGarry

Thanks, I had just discovered Qt Designer. I will probably use this. It
seems to work well.

Michael
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top