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. QRadioButton elements inside a QlistWidget
QtWS25 Last Chance

QRadioButton elements inside a QlistWidget

Scheduled Pinned Locked Moved General and Desktop
qradiobuttonqlistwidget
6 Posts 2 Posters 4.6k Views
  • 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
    CodeVisio
    wrote on 3 May 2015, 16:10 last edited by
    #1

    Hello everyone,

    I'm a new QT developer.
    What I'd like to have as end result is a QListWidget where the list's items are QRadioButtons.
    Is that possible? And if it is, how could I implement that? Are there any examples to look from?

    Thank you

    P 1 Reply Last reply 3 May 2015, 16:39
    0
    • C CodeVisio
      3 May 2015, 16:10

      Hello everyone,

      I'm a new QT developer.
      What I'd like to have as end result is a QListWidget where the list's items are QRadioButtons.
      Is that possible? And if it is, how could I implement that? Are there any examples to look from?

      Thank you

      P Offline
      P Offline
      p3c0
      Moderators
      wrote on 3 May 2015, 16:39 last edited by p3c0 5 Mar 2015, 16:39
      #2

      Hi @CodeVisio,
      Yes it is possible

      • Create new QListWidgetItem
      • Create new QRadioButton
      • Use setItemWidget to add that RadioButton as a List item in QListWidget
        For eg:
      QListWidget *list = new QListWidget();
      QListWidgetItem *listitem = new QListWidgetItem();
      list->setItemWidget(listitem,new QRadioButton("Radio Button"));
      

      157

      1 Reply Last reply
      0
      • C Offline
        C Offline
        CodeVisio
        wrote on 3 May 2015, 16:53 last edited by
        #3

        Hi p3c0,

        thank you for the answer.

        How about the click notifications? How can I be notified about the user click?

        Thanks

        P 1 Reply Last reply 3 May 2015, 17:11
        0
        • C CodeVisio
          3 May 2015, 16:53

          Hi p3c0,

          thank you for the answer.

          How about the click notifications? How can I be notified about the user click?

          Thanks

          P Offline
          P Offline
          p3c0
          Moderators
          wrote on 3 May 2015, 17:11 last edited by p3c0 5 Apr 2015, 09:19
          #4

          @CodeVisio
          Use itemClicked(QListWidgetItem*) signal
          and then for that item use itemWidget() method to access widget inside it.

          157

          1 Reply Last reply
          0
          • C Offline
            C Offline
            CodeVisio
            wrote on 3 May 2015, 17:19 last edited by
            #5

            Thanks a lot @p3c0.

            One more thing.
            I can use QListWidget with check boxes (shown like QCheckBox) as elements inside it without
            this approach list->setItemWidget( listitem, new QCheckBox() ) , while for QRadioBoxes I have to explicitly create those object before inserting them inside the list.
            Is that a design choice? or is there a way to show QRadioBoxes inside the list as I can do with QCheckBoxes without creating them?

            Thanks again

            P 1 Reply Last reply 3 May 2015, 17:30
            0
            • C CodeVisio
              3 May 2015, 17:19

              Thanks a lot @p3c0.

              One more thing.
              I can use QListWidget with check boxes (shown like QCheckBox) as elements inside it without
              this approach list->setItemWidget( listitem, new QCheckBox() ) , while for QRadioBoxes I have to explicitly create those object before inserting them inside the list.
              Is that a design choice? or is there a way to show QRadioBoxes inside the list as I can do with QCheckBoxes without creating them?

              Thanks again

              P Offline
              P Offline
              p3c0
              Moderators
              wrote on 3 May 2015, 17:30 last edited by p3c0 5 Apr 2015, 09:21
              #6

              @CodeVisio
              For checkboxes I think you must have set Qt::ItemIsUserCheckable flag for QListWidgetItem. So there's a way to do so. But for radiobutton theres none and thus have to create the widget explicitly.

              Edit: Links

              157

              1 Reply Last reply
              0

              1/6

              3 May 2015, 16:10

              • Login

              • Login or register to search.
              1 out of 6
              • First post
                1/6
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved