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. Inexplicable QToolBox bad behavior

Inexplicable QToolBox bad behavior

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 167 Views
  • 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.
  • enjoysmathE Offline
    enjoysmathE Offline
    enjoysmath
    wrote on last edited by
    #1
    def add_subtool_type(self, tool, title=None):
       if title is None:
          title = tool.title()
       self.toolsCombo.addItem(title, userData=tool)
       i = self.toolsCombo.count() - 1
       print (i)            # prints 5
       print(self.toolsCombo.itemData(i))    # prints that the object is there
       
    def add_subtool_instance(self, tool):
       if isinstance(tool, int):
          tool = self.toolsCombo.itemData(tool)   # App crashes here, though tool = 5
       if tool:  # else must be "Add tool" drop down item
          import dill as pickle
          data = pickle.dumps(tool)
          copy = pickle.loads(data)
          self.toolbox.addItem(copy)
          self.toolbox.setItemText(copy.title())
    

    Hi, when I receive currentIndexChanged signal from QComboBox, I call the second function. It's crashing my app. My app is very short, only about 10 files by now, because I started it yesterday.

    Anyway, this is halting development. I kind of need that associated data, but I'll try a dictionary too.

    https://github.com/enjoysmath
    https://math.stackexchange.com/users/26327/exercisingmathematician

    1 Reply Last reply
    0
    • enjoysmathE Offline
      enjoysmathE Offline
      enjoysmath
      wrote on last edited by
      #2

      Solution is to use a dictionary called _indexMap

      https://github.com/enjoysmath
      https://math.stackexchange.com/users/26327/exercisingmathematician

      1 Reply Last reply
      0

      • Login

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