Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. checking text from Table View in ComboBox or RadioButton/GroupBox
Forum Updated to NodeBB v4.3 + New Features

checking text from Table View in ComboBox or RadioButton/GroupBox

Scheduled Pinned Locked Moved Unsolved Qt for Python
4 Posts 2 Posters 401 Views
  • 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.
  • Karoluss96K Offline
    Karoluss96K Offline
    Karoluss96
    wrote on last edited by
    #1

    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!

    jsulmJ 1 Reply Last reply
    0
    • Karoluss96K Karoluss96

      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!

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @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!

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • Karoluss96K Offline
        Karoluss96K Offline
        Karoluss96
        wrote on last edited by Karoluss96
        #3

        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.

        jsulmJ 1 Reply Last reply
        0
        • Karoluss96K Karoluss96

          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.

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by jsulm
          #4

          @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?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved