Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Forum Updated on Feb 6th

    [Solved] Issue with insertRow

    General and Desktop
    2
    3
    521
    Loading More Posts
    • 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
      lukeQt last edited by lukeQt

      Hi Everyone,

      I have a QtSql.QSqlRelationalTableModel and a tableView. I can insertRows just fine. If the index is not valid though a blank row is added to the view, but not the model. How do you prevent adding a row to the view if no row is added to the model first? Correct me if I am wrong but insertRow adds a row to the view first and then to the model. This happens when the user does not specify a value in the tablemodel. How can you validate that the user has specified a value before adding another row. I was looking at dataChanged, but was not sure how to use this.

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

        It depends on how you submit the data to the database. Which mode are you using ?

        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 Reply Quote 0
        • L
          lukeQt last edited by

          I was using the default submit mode which I believe is the OnFieldChange. I guess then I need to use the OnManualSubmit.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post