Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-1772

wrapped type that inherits after template cant cast to type that template inherits from.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P4: Low
    • None
    • 6.2.2
    • Shiboken
    • None
    • All

    Description

      i'll describe this problem with code:

       

      cpp code:

      class ISerializable
      {
      public:
          std::string addToState(std::string& _state, const ISerializable& _value, const std::string& _label = "") const
          { 
              addToString(_state, &_value, _label); 
              return _state; 
          }
      };
      
      class ExtBaseUiElement
      {
      };
      
      template<class Tui, class Tval>
      class ExtUiElement : public ExtBaseUiElement, public ISerializable
      {
      };
      
      class ExtCheckBox
      {
      };
      
      class ExtCheckBoxBool : public ExtUiElement<ExtCheckBox, bool>
      {
      };
      
      class GuiChart : public ISerializable
      {
      };
      

       

      typesystem.xml:

      <object-type name="ISerializable"/>
      <object-type name="GuiChart"/>
      <object-type name="ExtBaseUiElement"/>
      <object-type name="ExtUiElement" generate="no"/>
      <object-type name="ExtComboBox" generate="no"/>
      <object-type name="ExtUiElement&lt;ExtCheckBox,bool&gt;" generate="no"/>
      <object-type name="ExtCheckBoxBool"/>
      

       

      python code:

      import AppLib
      
      chart = AppLib.GuiChart()
      checkbox = AppLib.ExtCheckBoxBool()
      
      state = ""
      state = self.addToState(state, chart , "chart")  # works
      state = self.addToState(state, checkbox , "checkbox")  # not working
      

       

      normally wrapped functions that expects base classes can take in types that derive from that base class (and it works nicely - as it should) - however the problem happens when we try to wrap type that inherits after template - which inherit after that base class.

       

      shiboken complains (at the run time) - that it doesnt see function with needed type.

      for now we work-around this by creating function overloads that expects exactly that type - and it works nicely however that doesnt look good in the code and in the documentation - alot of redundant functions in a few classes.

       

      is it a bug or it is a limitation by design?

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            kleint Friedemann Kleint
            meomic Michal M
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes