जब मैं करने के लिए (मूल रूप से) एक ही मुद्दा समाधान यह पता लगाने की कोशिश की के रूप में मैं इस सवाल का, पाया: मेरे मामले में मैं pyside में एक QScrollArea में एक QComboBox (अजगर क्यूटी lib) करना चाहते थे।
यहाँ मेरी नए सिरे से परिभाषित QComboBox वर्ग:
#this combo box scrolls only if opend before.
#if the mouse is over the combobox and the mousewheel is turned,
# the mousewheel event of the scrollWidget is triggered
class MyQComboBox(QtGui.QComboBox):
def __init__(self, scrollWidget=None, *args, **kwargs):
super(MyQComboBox, self).__init__(*args, **kwargs)
self.scrollWidget=scrollWidget
self.setFocusPolicy(QtCore.Qt.StrongFocus)
def wheelEvent(self, *args, **kwargs):
if self.hasFocus():
return QtGui.QComboBox.wheelEvent(self, *args, **kwargs)
else:
return self.scrollWidget.wheelEvent(*args, **kwargs)
जो इस तरह से प्रतिदेय है:
self.scrollArea = QtGui.QScrollArea(self)
self.frmScroll = QtGui.QFrame(self.scrollArea)
cmbOption = MyQComboBox(self.frmScroll)
यह मूल रूप से emkey08's answerlink Ralph Tandetzky pointed out में है, लेकिन अजगर में इस समय।
स्रोत
2017-04-18 08:33:17
मैंने क्लिक करने के लिए combobox की फोकस नीति भी बदल दी। इससे भी मदद मिली। धन्यवाद! –
लेकिन अगर मैं इसके ऊपर पहिया हूं तो QComboBox अभी भी फोकस किया गया है। क्यूं कर? इसे कैसे रोकें? मैं फोकस अक्षम नहीं करना चाहता हूं बल्कि केवल पहिया पर ध्यान केंद्रित करना चाहता हूं। – 18C