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. How to set a comboBox Text an empty string if the index is 0?
Forum Updated to NodeBB v4.3 + New Features

How to set a comboBox Text an empty string if the index is 0?

Scheduled Pinned Locked Moved Solved Qt for Python
3 Posts 2 Posters 537 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.
  • L Offline
    L Offline
    LT-K101
    wrote on 22 Jul 2022, 10:35 last edited by
    #1

    I want to set a comboBox text to an empty string when the comboBox index is 0. I tried the code below but it exits my application. Please any help on what am doing wrong. Thanks in advance.

    Check = " "
    qualification = self.ui.qualification_comboBox.currentText()
            if self.ui.qualification_comboBox.currentIndex() == 0:
                self.ui.qualification_comboBox.setCurrentText(Check)
    
    J 1 Reply Last reply 22 Jul 2022, 10:36
    0
    • L LT-K101
      22 Jul 2022, 10:35

      I want to set a comboBox text to an empty string when the comboBox index is 0. I tried the code below but it exits my application. Please any help on what am doing wrong. Thanks in advance.

      Check = " "
      qualification = self.ui.qualification_comboBox.currentText()
              if self.ui.qualification_comboBox.currentIndex() == 0:
                  self.ui.qualification_comboBox.setCurrentText(Check)
      
      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 22 Jul 2022, 10:36 last edited by jsulm
      #2

      @LT-K101 said in How to set a comboBox Text an empty string if the index is 0?:

      I tried the code below but it exits my application

      So, did you use debugger to see what happens and to provide stack trace here, so others can check what happens?
      Also the string you're setting is not empty.

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

      L 1 Reply Last reply 22 Jul 2022, 12:49
      2
      • J jsulm
        22 Jul 2022, 10:36

        @LT-K101 said in How to set a comboBox Text an empty string if the index is 0?:

        I tried the code below but it exits my application

        So, did you use debugger to see what happens and to provide stack trace here, so others can check what happens?
        Also the string you're setting is not empty.

        L Offline
        L Offline
        LT-K101
        wrote on 22 Jul 2022, 12:49 last edited by
        #3
        This post is deleted!
        1 Reply Last reply
        0

        1/3

        22 Jul 2022, 10:35

        • Login

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