Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] QDataWidgetMapper, clearing associated QLineEdit's when table is empty
Qt 6.11 is out! See what's new in the release blog

[SOLVED] QDataWidgetMapper, clearing associated QLineEdit's when table is empty

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 3.1k 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.
  • I Offline
    I Offline
    i92guboj
    wrote on last edited by
    #1

    Hi.

    I have been wondering about this for some weeks, but I had some other things to worry about. Still, I've been looking into this every now and then and I can't really figure this out.

    I have a QTableView, tied to a QSqlTableModel. I also have a QDataWidgetMapper, which I used to sync the table with a QLineEdit based form where I can enter and edit records from my QSqlTableModel.

    The final piece is a function that I use to remove all the records in the table. That works, however, while the table becomes empty as it must, the QLineEdits will still hold the last values after the table has been cleaned.

    I could of course blank them "by hand" in the same function I use to erase all the records, but I am wondering if there isn't any more "straight" way to do this.

    I use QSqlTableModel::removeRows() along with rowCount() to remove the whole table. As said, the table widget empties itself. But the thing doesn't propagate into the QWidgetMapper for some reason, or maybe that's the intended behaviour...

    Thanks for any response, or just for reading :)

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

      Hi,

      I wonder if the index of the mapper is updated while your remove the rows

      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
      • I Offline
        I Offline
        i92guboj
        wrote on last edited by
        #3

        [quote author="SGaist" date="1377034234"]Hi,

        I wonder if the index of the mapper is updated while your remove the rows[/quote]

        I don't know what the correct behaviour would be, but the mapper->currentIndex() reports -1 after the removeRows() sentence.

        Thanks :)

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

          That would be the correct index.

          But whether the QDataWidgetMapper should clear the widget's content is more a question for the interest mailing list, you'll find there Qt's developers/maintainers (this forum is more user oriented)

          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
          • I Offline
            I Offline
            i92guboj
            wrote on last edited by
            #5

            [quote author="SGaist" date="1377099893"]That would be the correct index.

            But whether the QDataWidgetMapper should clear the widget's content is more a question for the interest mailing list, you'll find there Qt's developers/maintainers (this forum is more user oriented)[/quote]

            Oh, I am not really concerned about that for now.

            Don't take me wrong, I am concerned about some things, and would be willing to help a bit, but my own ignorance would be nothing but a hindrance to any mailing list for now.

            I was just wondering if that was the intended behaviour of a QDataWidgetMapper instance.

            Even within my limited understanding of nowadays Qt, I can think of several ways to clean the fields in a more or less automated way.

            Thank you for clearing my doubt :)

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

              You welcome !

              This question would as valid as any, don't worry,

              Happy coding :)

              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

              • Login

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