質問

I'm new to PyQT and GUI dev in general, I'm getting grasp of the connectors but the Tabs Widget I can't seem to make work.

I'm trying this code:

QtCore.QObject.connect(self.tabsFrame, QtCore.SIGNAL(_fromUtf8("tabBarClicked(int)")), self.myFunction)

(auto generated by the QtCreator)

but I doesn't seem to do anything.

The buttons I can make work because they have the 'new' syntax (button.clicked.connect(function), but this don't.

役に立ちましたか?

解決

You're probably using a PyQt/Qt version that is too old.

The tabBarClicked signal was only introduced in Qt5.2, and because of the old-style syntax your're probably using PyQt4 (as in PyQt5 QObject.connect is gone).

You're not getting an error because in old-style PyQt4, signals are defined implicitly when used, so your code works, but the signal is just never emitted.

You could just use the currentChanged signal instead.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top