Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Mapping QWidget Using SignalMapper with PyQt
Forum Updated to NodeBB v4.3 + New Features

Mapping QWidget Using SignalMapper with PyQt

Scheduled Pinned Locked Moved General and Desktop
3 Posts 1 Posters 2.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    wejou
    wrote on 18 Jun 2014, 22:58 last edited by
    #1

    Hi all,

    I have been really struggling with using SignalMapper with PyQt.

    First, here's what I would like to do. I am using the model/view architecture with a table view. To keep it simple, let's say that I have two columns A and B. Column A consists of only QCheckBox's and column B has only QLineEdit's. When the checkbox in row i, column A is unchecked, I want to set the QLineEdit in row i, Column B as read only (i.e. gray it out). Therefore, I figure I need a reference to the QCheckbox that was toggled so that I can adjust the correct QLineEdit. This why I use signalMapper so that, immediately after the toggle, I can pass a reference to the toggled checkbox as a parameter to my custom slot.

    Everything works fine when I do something like:
    @
    mapper = QSignalMapper()
    checkBox = model.indexWidget(row,col)
    checkBox.toggled.connect(mapper.map)
    mapper.setMapping(checkBox, int)
    mapper.mapped[int].connect(self.someCustomSlot)
    @

    But if I try to pass a Qt object(such as QWidget) like:

    @
    mapper = QSignalMapper()
    checkBox = model.indexWidget(row,col)
    checkBox.toggled.connect(mapper.map)
    mapper.setMapping(checkBox, checkBox)
    mapper.mapped[QWidget].connect(self.someCustomSlot)
    @

    It gives me the following error on Line 5: "KeyError: 'there is no matching overloaded signal'".

    Due to the error message, I think that there may be an issue with the way that I am calling the signal named "mapped" on Line 5.

    Is this a good case for a signal mapper? If not, then what would you recommend. If necessary, I can post my exact code tomorrow.

    1 Reply Last reply
    0
    • W Offline
      W Offline
      wejou
      wrote on 19 Jun 2014, 12:29 last edited by
      #2

      Update:

      I found it easier just to pass a str to the signal named "mapped". The str consisted of the row and column of the toggled checkbox separated by a comma. Then, in my slot, i just used the str.split(',') to get the row and column.

      Everything works as desired now.

      1 Reply Last reply
      0
      • W Offline
        W Offline
        wejou
        wrote on 20 Jun 2014, 16:54 last edited by
        #3

        Though I have a solution, does anyone know how to pass in a non-Python type to the mapped signal ?

        1 Reply Last reply
        0

        1/3

        18 Jun 2014, 22:58

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved