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. QSqlRelationalTableModel/QDataWidgetMapper and empty model
Forum Updated to NodeBB v4.3 + New Features

QSqlRelationalTableModel/QDataWidgetMapper and empty model

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 3.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.
  • C Offline
    C Offline
    cotecmania
    wrote on last edited by
    #1

    Hello,

    I have a working model and mapper (Qt4.7) and the values are shown in several widgets (lineedits,combos).
    The connections are made with "addMapping".
    If i set a filter (model->setFilter("...")) to my modell which leads to zero data in the model, my widgets are not cleared.
    They keep their values from the last entry before setting the filter.
    How can i solve this ?

    Thanks in Advance

    1 Reply Last reply
    0
    • F Offline
      F Offline
      fluca1978
      wrote on last edited by
      #2

      An index problem?

      @QModelIndex index = tableView->currentIndex();
      widgetMapper->setCurrentIndex( index.row() );@

      I think you have to inform the mapper that the index is no more valid, so it can clean the widgets.

      1 Reply Last reply
      0
      • C Offline
        C Offline
        cotecmania
        wrote on last edited by
        #3

        Hello,

        Now I found out something strange. Some widgets are cleared and some are not !
        My model connects to an Access-mdb. All fields which are text-type are cleared correctly, but all other fields like numbers, date or currency keep their values of before.
        This is the same behaviour if i add a new row.
        How can i handle these datatypes the same way like the textfields ?

        Thanks

        1 Reply Last reply
        0
        • C Offline
          C Offline
          cotecmania
          wrote on last edited by
          #4

          Hello,

          You can reproduce this problem by modifying the Qt Example "SQL Widget Mapper"
          If you add these lines to the example and connect it with a new button you can see that the widgets stay like they are (not cleared), but the model ist empty because of the filter.

          @void Window::setFilter()
          {
          model->setFilter("name=berta");
          mapper->toFirst();
          }
          @

          Please help !

          1 Reply Last reply
          0
          • C Offline
            C Offline
            cotecmania
            wrote on last edited by
            #5

            Solution ! revert() did the job :

            @void Window::setFilter()
            {
            model->setFilter("name=berta");
            mapper->revert();
            }@

            1 Reply Last reply
            0
            • B Offline
              B Offline
              broadpeak
              wrote on last edited by
              #6

              Have you got this line?:
              @
              mapper->setSubmitPolicy(QDataWidgetMapper::AutoSubmit);
              @

              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