def text_to_qcolor(text):
 color = QColor()
 text = str(text)
 if (not is_text_string(text)):
  return color
 if (text.startswith('#') and (len(text) == 7)):
  correct = '#0123456789abcdef'
  for char in text:
   if (char.lower() not in correct):
    return color
 elif (text not in list(QColor.colorNames())):
  return color
 color.setNamedColor(text)
 return color

def text_to_qcolor ( text ) : color = QColor ( ) text = str ( text ) if ( not is_text_string ( text ) ) : return color if ( text . startswith ( '#' ) and ( len ( text ) == 7 ) ) : correct = '#0123456789abcdef' for char in text : if ( char . lower ( ) not in correct ) : return color elif ( text not in list ( QColor . colorNames ( ) ) ) : return color color . setNamedColor ( text ) return color
create a qcolor from specified string avoid warning from qt when an invalid qcolor is instantiated .