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 make the item checked while i click the item in a QListWidget?
Forum Update on Monday, May 27th 2025

How to make the item checked while i click the item in a QListWidget?

Scheduled Pinned Locked Moved General and Desktop
8 Posts 3 Posters 3.8k 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.
  • O Offline
    O Offline
    opengpu
    wrote on last edited by
    #1

    how to make the item checked while i click the item?
    i want to make the item checked/unchecked while i click the item

    1 Reply Last reply
    0
    • IamSumitI Offline
      IamSumitI Offline
      IamSumit
      wrote on last edited by
      #2

      Hi.

      Asked already ,,
      "here":http://qt-project.org/forums/viewthread/9914

      Be Cute

      1 Reply Last reply
      0
      • O Offline
        O Offline
        opengpu
        wrote on last edited by
        #3

        i set ItemIsUserCheckable, but still can't get the effect i want.
        i now setCheckState(Qt::Unchecked) to make the ListItem having a checkbox in font of the icon and text.
        i just want to make the item checked/unchecked no matter where i click on the item, not i have to click the checkbox there, but i want the check state to change even when i click on the text and icon (whick mean when i select the item, i want it checked/unchecked)

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

          Hi,

          That you'll have to do by hand using e.g. the itemClicked signal

          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
          • O Offline
            O Offline
            opengpu
            wrote on last edited by
            #5

            thank you :)
            and how to do this?
            i want to make 1 item checked all the time,
            i now tried a most common way: in clickedItem slot, if i checked the current item, first of it , i make all the checked items unchecked....
            but i found there is no fast way to do this, eg. there is no API to get all the items or the row number

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

              Can you described exactly what you are trying to achieve with that selection ?

              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
              • O Offline
                O Offline
                opengpu
                wrote on last edited by
                #7

                actually, i want the only 1 item is selected & 1 item checked at most.
                why i thought selected is not enough is that, if i use checked/unchecked, i can make them all unchecked.However, there seems no way to get all items unselected.

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

                  Only one item selected is easy to do, just enforce using SingleSelection. However that doesn't explain why the checkbook

                  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