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. QSQLQuery is not null
Qt 6.11 is out! See what's new in the release blog

QSQLQuery is not null

Scheduled Pinned Locked Moved Unsolved Qt for Python
3 Posts 3 Posters 744 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,

    In documentation of QsqlQuery we have functions isNull()
    OK, but... is there function to other side (like title 'isNotNull')?

    I my current code I don't need NULL values to put into comboBox, but option if isnull else:... is too long (and in if I needen't write anything)?

    Have you some idea to solve it (make code shorter)?

    Current code looks that:

    if query.record().isNull("DATE_TO_TAKE"):
             print (query.record().value("DATE_TO_TAKE"))#Don't need it
    else:    
            self.dlg.comboBox_20.addItem(query.record().value(""DATE_TO_TAKE").toString('dd.MM.yyyy')) #This is correct
    
    jsulmJ JonBJ 2 Replies Last reply
    0
    • Karoluss96K Karoluss96

      Hi everyone,

      In documentation of QsqlQuery we have functions isNull()
      OK, but... is there function to other side (like title 'isNotNull')?

      I my current code I don't need NULL values to put into comboBox, but option if isnull else:... is too long (and in if I needen't write anything)?

      Have you some idea to solve it (make code shorter)?

      Current code looks that:

      if query.record().isNull("DATE_TO_TAKE"):
               print (query.record().value("DATE_TO_TAKE"))#Don't need it
      else:    
              self.dlg.comboBox_20.addItem(query.record().value(""DATE_TO_TAKE").toString('dd.MM.yyyy')) #This is correct
      
      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Karoluss96 said in QSQLQuery is not null:

      isNotNull

      Isn't it the same as !isNull?
      Or did I misunderstand your question?

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

      1 Reply Last reply
      1
      • Karoluss96K Karoluss96

        Hi everyone,

        In documentation of QsqlQuery we have functions isNull()
        OK, but... is there function to other side (like title 'isNotNull')?

        I my current code I don't need NULL values to put into comboBox, but option if isnull else:... is too long (and in if I needen't write anything)?

        Have you some idea to solve it (make code shorter)?

        Current code looks that:

        if query.record().isNull("DATE_TO_TAKE"):
                 print (query.record().value("DATE_TO_TAKE"))#Don't need it
        else:    
                self.dlg.comboBox_20.addItem(query.record().value(""DATE_TO_TAKE").toString('dd.MM.yyyy')) #This is correct
        
        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by JonB
        #3

        @Karoluss96
        Python:

        if not query.record().isNull("DATE_TO_TAKE"):
                self.dlg.comboBox_20.addItem(query.record().value(""DATE_TO_TAKE").toString('dd.MM.yyyy')) #This is correct
        
        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