Unsolved checking text from Table View in ComboBox or RadioButton/GroupBox
-
Hi everyone,
I have a problem in creating the function in which I plan to compare that putted in TableView (in editig mode) is correct - exist in ComboBox (from which user can choose value to put new record in TableView) or grouped in GroupBox Radio Buttons (the same road to create/add new record into Table View).
Currenct version looks that:
#for comboBox if rowData[4].replace('\'','')) != self.dlg.comboBox_18.findText(rowData[4].replace('\'','')): print ((self.dlg.comboBox_18.findText(rowData[4].replace('\'','')))) print ('bad value') else: print('good value') #for GroupBox with Radio Buttons: if rowData[6].replace('\'','') not in self.dlg.groupBox_5.toggled(True): print ('bad value') else: print('good value')
rowData came from Table View (eg. [4]= 'UM16' [6]='akt')
comboBox_18 have got values ['UM02', 'UM04', 'UM06'...]GroupBox has hot 3 independent RadioButtons. One of them carry value 'akt'
If isn't understand what I mean please ask to explain more theory of my idea with this problem
Thanks for every kind of help!
-
@Karoluss96 said in checking text from Table View in ComboBox or RadioButton/GroupBox:
if rowData[4].replace(''','')) != self.dlg.comboBox_18.findText(rowData[4].replace(''',''))
You are comparing a string with an integer.
Please read documentation for methods you are using (https://doc.qt.io/qt-5/qcombobox.html#findText)Line bellow also makes no sense:
if rowData[6].replace('\'','') not in self.dlg.groupBox_5.toggled(True):
https://doc.qt.io/qt-6/qgroupbox.html#toggled is a SIGNAL!
-
I delete toogled to a different version.
I read ([red] - Past Simple) the part about findText in chapter about Combobox. I need the function that comparing 2 strings not String with integer.
So is in combobox functions one that can take the text from ComboBox not his index, but I can't find matching exactly function to my problem.
-
@Karoluss96 said in checking text from Table View in ComboBox or RadioButton/GroupBox:
So is in combobox functions one that can take the text from ComboBox not his index
Yes. And you're already using it. But the code you wrote makes no sense.
Did you read https://doc.qt.io/qt-5/qcombobox.html#findText carefully?
"Returns the index of the item containing the given text; otherwise returns -1."
Based on this description, what are you trying to achieve with this line of code:if rowData[4].replace('\'','')) != self.dlg.comboBox_18.findText(rowData[4].replace('\'','')):
?
" I need the function that comparing 2 strings not String with integer" - what exactly do you want to compare?