I have a QWidget that contains QLabels and QLineEdits side by side.
When I click on a QLabel, I can use the mousePressEvent in QWidget. But when I click on QLineEdit, I can't detect the mousePressEvent in QWidget - only in the QLineEdit. I think that it is related to how QLineEdit works - I don't know the way to get mouse events within the whole region.
EDIT:
I have made a custom channel box for Maya like above. I try to select multiple channels by dragging the mouse. But as I mentioned, in the QLineEdit regions I can't do this.
class channelWidget(QtGui.QWidget):
def __init__(self, parent=None):
super(channelWidget, self).__init__(parent)
self.resize(180, 20)
self.setMinimumSize(180, 20)
self.setMaximumHeight(20)
self.attr_label = QtGui.QLabel(self)
self.attr_label.setGeometry(QtCore.QRect(5, 0, 110, 20))
self.attr_label.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.value_field = focusLineEdit(self)
self.value_field.setGeometry(QtCore.QRect(120, 0, 60, 20))
self.value_field.setAlignment(QtCore.Qt.AlignLeft|QtCore.Qt.AlignLeading|QtCore.Qt.AlignVCenter)
self.value_field.setValidator(QtGui.QDoubleValidator())
Each element consists of a QLabel and a QLineEdit.
class channelContainerWidget(QtGui.QWidget):
def updateChannel(self, node="", attrList=[]):
_l = self.channel_layout
_list = []
for w in [_l.itemAt(i).widget() for i in range(_l.count()) if _l.itemAt(i).widget()]:
if w in self._selectList: _list.append( str( w.attr_label.text() ) )
sip.delete(w)
_selList = []
for _id, at in enumerate(attrList):
_item = channelWidget(self)
_item.attr_label.setText(at)
_item.value_field.setText(value)
_l.insertWidget(_id, _item)
And the containing widget works as above. When I click on QLabel region, I can get mouse events, but when I click on the QLineEdit region, I can't.