Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved Inexplicable QToolBox bad behavior

    General and Desktop
    1
    2
    48
    Loading More Posts
    • 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.
    • enjoysmath
      enjoysmath last edited by

      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 Reply Quote 0
      • enjoysmath
        enjoysmath last edited by

        Solution is to use a dictionary called _indexMap

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

        1 Reply Last reply Reply Quote 0
        • First post
          Last post