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] How to save data (e.g a path of an image) in a listwidget item?
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] How to save data (e.g a path of an image) in a listwidget item?

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

    we have a listwidget, and you add an image.. what i did until now was to save the path of the image as statustip withouth having statusbar, so when i needed the path i just called ui->listwidget->item(1)->statustip..

    but this seems just wrong, is there anything for that purpose.. the path must not be visible to user at any time...

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      Use data and setData with custom roles. You might need to subclass QListWidgetItem to store that additional data.

      1 Reply Last reply
      0
      • L Offline
        L Offline
        Leon
        wrote on last edited by
        #3

        Thanks andrew.. so if i want to have a text that i don't want the user to see i should use
        setData(11,text here)?

        i mean role 11 is the correct one for a text?

        works for me just don't know if it is the correct one..

        1 Reply Last reply
        0
        • L Offline
          L Offline
          Leon
          wrote on last edited by
          #4

          *bump Anyone.. Is the role 11 the correct one?

          1 Reply Last reply
          0
          • K Offline
            K Offline
            KA51O
            wrote on last edited by
            #5

            I'm not sure about the use of Qt::AccessibleTextRole (11) for this purpose. You can also define your own Role for this. See "ItemDataRole documentation":http://qt-project.org/doc/qt-4.8/qt.html#ItemDataRole-enum

            bq. Qt::UserRole 32 The first role that can be used for application-specific purposes.

            bq. For user roles, it is up to the developer to decide which types to use and ensure that components use the correct types when accessing and setting data.

            1 Reply Last reply
            0
            • sierdzioS Offline
              sierdzioS Offline
              sierdzio
              Moderators
              wrote on last edited by
              #6

              No, you should use 32 or greater value. 11 is reserved for accessibility.

              (Z(:^

              1 Reply Last reply
              0
              • L Offline
                L Offline
                Leon
                wrote on last edited by
                #7

                [quote author="sierdzio" date="1347267425"]No, you should use 32 or greater value. 11 is reserved for accessibility.[/quote]

                Thank you!

                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