1

I'm trying to understand the itemChanged signal to be able to update some information. An example of what I'm trying to achieve could be:

def setCoordText(): label1.setText(str(label1.x()) + "," + str(label1.y()))

label1.itemChanged.connect(setCoordText)

so that when the label is moved to another location, it would display the new coordinates. What is wrong/missing here? Why nothing happens?

  • It makes no sense. What is label1? – dmh126 Dec 22 '15 at 1:18
  • a label on the composer, but I don't think it really matters: any item with the itemChanged signal will do. – andy Dec 22 '15 at 1:33
  • This signal is emitted when the object is changed. For example you have an item in the table and you change this item (insert new text, delete or whatever). – dmh126 Dec 22 '15 at 1:38
  • That's the theory, but it is not working. I made a connection with extentChanged.connect(myfun) and works fine, but with itemChanged it is not. I don't know if it is limited to some data and others not. In my case I want to get the signal when the position (label1.x and label1.y) changes. – andy Dec 22 '15 at 1:46
  • I just found out that it works if the label is moved and undone (Ctrl+z). So how can I trigger the setCoordText() function just by moving the label? Why it works after undoing and not with the change itself? – andy Dec 24 '15 at 17:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.