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. How to map QRadioButtons to a QDataWidgetMapper
Forum Updated to NodeBB v4.3 + New Features

How to map QRadioButtons to a QDataWidgetMapper

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 2 Posters 1.5k 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.
  • P Offline
    P Offline
    Panoss
    wrote on last edited by
    #1

    I have two radio buttons in a QGropBox, grouped together in one group.
    So, haw can I map them to a mapper?
    I 'll put: mapper->..and then what?

    They must be mapped o a field from db, named paid.
    When paid is 1, I want radio1 to be checked (and radio 2 unchecked).
    When paid is 0 or empty, I want radio2 to be checked (and radio 1 unchecked).

    1 Reply Last reply
    0
    • P Offline
      P Offline
      Panoss
      wrote on last edited by Panoss
      #2

      I found this, works for reading the QRadioButtons.
      But the value of the Radio group does not get stored in the database.
      How can I add this feature? (I mean without using model->setData method)

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

        Hi,

        Do you mean the the mapper doesn't update the model ?

        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
        • P Offline
          P Offline
          Panoss
          wrote on last edited by Panoss
          #4

          I don't know if the mapper updates the model(can I check this somehow?).
          I only know that db does not get updated.(when I m not using the setData)
          (let me explain: I use model->setData() to insert the RadioGroup 's value in the model. Works fine and gets saved in db. I was just thinking if it 's possible to remove model->setData(), modifying, somehow, the code of the class OptionGroup)

          1 Reply Last reply
          0
          • P Offline
            P Offline
            Panoss
            wrote on last edited by Panoss
            #5

            I want to make a function clear() in the class OptionGroup, which will set all Radio buttons of the Group to false.
            This is the code in the function, but does not set Radio buttons to false. It does nothing:

                foreach (QRadioButton *RadioButton, buttonMap_){
                    RadioButton->setChecked(false);
                    qDebug()<< RadioButton->objectName();
                }
                currentSelection_ = false;
                emit selectionChanged(currentSelection_);
            

            How can I do this?

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

              See this stackoverflow answer.

              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
              1
              • P Offline
                P Offline
                Panoss
                wrote on last edited by
                #7

                Thanks! setAutoExclusive did the job.

                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