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. QDataWidgetMapper and custom widget - read value
Forum Updated to NodeBB v4.3 + New Features

QDataWidgetMapper and custom widget - read value

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.8k 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.
  • H Offline
    H Offline
    Hostel
    wrote on last edited by
    #1

    I've made a my widget which has a Q_PROPERTY like this:
    @
    Q_PROPERTY(QDate date READ date WRITE setDate NOTIFY dateChanged USER true )
    @

    I created a QDataWidgetMapper and addMapping. The date from my widget is not readed by mapper. Even there is not invoked a date() method. What could be wrong? My class inherits from QFrame and has a Q_OBJECT macro.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mcosta
      wrote on last edited by
      #2

      Hi,

      Q_PROPERTY declares date() as function to read property value; you must define it.
      This means you need to declare and implement this function:

      @
      class YourClass: public QFrame
      {
      Q_OBJECT

      public:
      .....

      QDate date () const;
      

      };
      @

      Once your problem is solved don't forget to:

      • Mark the thread as SOLVED using the Topic Tool menu
      • Vote up the answer(s) that helped you to solve the issue

      You can embed images using (http://imgur.com/) or (http://postimage.org/)

      1 Reply Last reply
      0
      • H Offline
        H Offline
        Hostel
        wrote on last edited by
        #3

        I have methods.

        I use QSqlTableModel.
        My widget has QCheckBox and QDateEdit. I use delegate to format date for SQLite.

        I made tests and I added my delegate. I have two situations:

        1. Without mapper->setSubmitPolicy (default is QDataWidgetMapper::AutoSubmit).
          setModelData from delegate is invoked for Qt widgets(QDateEdit too) but not when I set value in my widget.

        2. With mapper->setSubmitPolicy( QDataWidgetMapper::ManualSubmit ).
          submit() is called whed dialog is accepted. In this case setModelData operates on Qt widgets and take value from my widget too.

        Is this a bug or maybe I'm doing something wrong?

        1 Reply Last reply
        0
        • H Offline
          H Offline
          Hostel
          wrote on last edited by
          #4

          I reported bug.
          https://bugreports.qt-project.org/browse/QTBUG-31119

          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