code: def _qt_set_leaf_data(self, qvar):
      if VERBOSE_PREF:
          print('')
          print('+--- [pref.qt_set_leaf_data]')
          print('[pref.qt_set_leaf_data] qvar = %r' % qvar)
          print('[pref.qt_set_leaf_data] _intern.name=%r' % self._intern.name)
          print('[pref.qt_set_leaf_data] _intern.type_=%r' % self._intern.get_type())
          print('[pref.qt_set_leaf_data] type(_intern.value)=%r' % type(self._intern.value))
          print('[pref.qt_set_leaf_data] _intern.value=%r' % self._intern.value)
      if self._tree.parent is None:
          raise Exception('[Pref.qtleaf] Cannot set root preference')
      if self.qt_is_editable():
          new_val = '[Pref.qtleaf] BadThingsHappenedInPref'
          if self._intern.value == PrefNode:
              raise Exception('[Pref.qtleaf] Qt can only change leafs')
          elif self._intern.value is None:
              def cast_order(var, order=[bool, int, float, six.text_type]):
                  for type_ in order:
                      try:
                          ret = type_(var)
                          return ret
                      except Exception:
                          continue
              new_val = cast_order(six.text_type(qvar))
          self._intern.get_type()
          if isinstance(self._intern.value, bool):
              print('qvar = %r' % (qvar,))
              new_val = util_type.smart_cast(qvar, bool)
              print('new_val = %r' % (new_val,))
          elif isinstance(self._intern.value, int):
              new_val = int(qvar)
          elif self._intern.get_type() in util_type.VALID_FLOAT_TYPES:
              new_val = float(qvar)
          elif isinstance(self._intern.value, six.string_types):
              new_val = six.text_type(qvar)
          elif isinstance(self._intern.value, PrefChoice):
              new_val = six.text_type(qvar)
              if new_val.upper() == 'NONE':
                  new_val = None
          else:
              try:
                  type_ = self._intern.get_type()
                  if type_ is not None:
                      new_val = type_(six.text_type(qvar))
                  else:
                      new_val = six.text_type(qvar)
              except Exception:
                  raise NotImplementedError(
                      ('[Pref.qtleaf] Unknown internal type. '
                       'type(_intern.value) = %r, '
                       '_intern.get_type() = %r, ')
                      % type(self._intern.value), self._intern.get_type())
          if isinstance(new_val, six.string_types):
              if new_val.lower() == 'none':
                  new_val = None
              elif new_val.lower() == 'true':
                  new_val = True
              elif new_val.lower() == 'false':
                  new_val = False
          if VERBOSE_PREF:
              print('---')
              print('[pref.qt_set_leaf_data] new_val=%r' % new_val)
              print('[pref.qt_set_leaf_data] type(new_val)=%r' % type(new_val))
              print('L____ [pref.qt_set_leaf_data]')
          return self._tree.parent.pref_update(self._intern.name, new_val)
      return 'PrefNotEditable'