Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. Application stalls with query/table models in PyQt5
Forum Updated to NodeBB v4.3 + New Features

Application stalls with query/table models in PyQt5

Scheduled Pinned Locked Moved Unsolved Language Bindings
7 Posts 2 Posters 2.2k Views 1 Watching
  • 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.
  • M Offline
    M Offline
    Melsion
    wrote on last edited by Melsion
    #1

    Hi, I'm working on a small application to access a database. I wrote it with PyQt4 but I'm now adapting it to PyQt5, really a piece of cake until now because the code is very simple.

    So simple, in fact, that I cannot find the reason it doesn't work with PyQt5 as it did with the previous version. I have various QDialogs for editing the contents of different tables using a QDataWidgetMapper. I create the data model like this:

    model = QSqlTableModel(self)
    model.setTable("myTable")

    and the execution stalls on that last line, no crash, no segmentation fault, nothing. It just stalls indefinitely. It happens the same with QSqlQueryModel when calling setQuery(), but only on some dialogs, others don't, and they are identical (only changes the table's name and the fields.

    Any clues? where should I look to fix this?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      You should add which version of Qt 5 you are using as well as QSL driver

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Melsion
        wrote on last edited by Melsion
        #3

        Hi and thank you!!!

        I've tried it with debian Jessie (Qt-5.3.2) and Stretch (Qt-5.4.2), also with Gentoo (Qt-5.4.2 I think). The driver is MySQL.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Did you check if you have any error from your database prior to setTable ?

          Is the MySQL server your own machine or another one ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • M Offline
            M Offline
            Melsion
            wrote on last edited by Melsion
            #5

            It is on another machine, but I don't think it's a mysql problem because, if I switch the headers back to PyQt4, the same code works perfectly under the same circumstances, and under PyQt5 other functions work well.

            Trying random things, I just discovered that if I change the code to:

            query = QSqlQuery("select * from my table")
            model = QSqlTableModel(self)
            model.setQuery(query)

            it works, though if I want to write the changes back to the database I'd have to rewrite the rest of the code... I'd rather use the WidgetMapper. If I execute a INSERT through a QSqlQuery works perfectly, so it's not a problem of permissions or malformed queries.

            I'm begining to think I've hit a bug in PyQt, but I can't find any valuable information. The backtrace only tells me that the program was halted while running the "setTable" line... could you point me in the right direction to debug this?

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Can you do a quick check of your current Qt 5 with a small C++ test application ? That way we can rule out whether it's Qt or PyQt at fault

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • M Offline
                M Offline
                Melsion
                wrote on last edited by
                #7

                Sorry, I've been pretty busy these days and looks like I'll be for a while, I'll get to it whenever I get some free time. Also, I've run into another problem, this time with the QtPrintSupport module, what it prints using Qt5 is completely different to what it prints in Qt4, among other things it completely ignores the margins settings, but right now I can't get to it. Thanks anyway!

                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