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] Assigning custom value to a check- or radiobox
Forum Updated to NodeBB v4.3 + New Features

[Solved] Assigning custom value to a check- or radiobox

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

    Consider the following two snippes;

    @value_t value;

    value = mUI.radioGroup->checkedButton().value(); // or something similar@

    vs

    @value_t value;

    if ( mUI.radioBtn1->isChecked() )
    {
    value = value1;
    }
    else if ( mUI.radioBtn2->isChecked() )
    {
    value = value2;
    }
    else
    {
    value = value3;
    }@

    The latter works, the former does not. Am I correct in that Qt does not provide us with a way of assigning an arbitrary value to a check- or radioBox? If so, why not? So far, my group consists of just three buttons but I can see how this quickly becomes a mess when the count goes up.

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

      Hi,

      You can use a "dynamic property":http://qt-project.org/doc/qt-5/properties.html#dynamic-properties for that.

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

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

        You can use a "dynamic property":http://qt-project.org/doc/qt-5/properties.html#dynamic-properties for that. [/quote]

        Exactly what I was looking for. Thank you. :)

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

          You're welcome !

          Since you have your software working now, please update the thread title prepending [solved] so other forum users may know a solution has been found :)

          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