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. QListWidget: what signal for "item edition start" event?
Forum Updated to NodeBB v4.3 + New Features

QListWidget: what signal for "item edition start" event?

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

    Hello,

    I am successfully using the QListWidget, and also reacting on text changes from the user side (with the itemChanged signal). The problem that I have is following:

    The list displays text items like "objectName (objectType)". When the user enters text edit mode for one item, the text should only display "objectName", since the user can only edit the object name part. Once edition is finished, the system will append the object type information to the string.

    Under MVS, once would use the OnBeginlabeledit and the OnEndlabeledit handlers.
    In Qt, itemChanged is equivalent to OnEndlabeledit. What would be the equivalent of OnBeginlabeledit?

    Thanks!

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on last edited by
      #2

      The easiest way would be, you create a "custom delegate":http://doc.qt.nokia.com/4.7/model-view-programming.html#delegate-classes

      The delegate creates the editor, sets tghe values to the editor and also sets it back to the view. So this is the perfect place for those things.

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

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

        You might considder using "QxtListWidget":http://libqxt.bitbucket.org/doc/0.6/qxtlistwidget.html instead of QListWidget. It has signals for these events.

        1 Reply Last reply
        0
        • F Offline
          F Offline
          floatingWoods
          wrote on last edited by
          #4

          Thanks a lot to both of you. The delegate solution works nicely :)

          1 Reply Last reply
          0
          • D Offline
            D Offline
            dangelog
            wrote on last edited by
            #5

            To be really really pedantic:

            • the "objectName (objectType)" form should be returned by your model as the DisplayRole for that index;
            • the "objectName" for the EditRole;
            • when you write a new object name, setData is called for the EditRole -- and therefore your model should append the new object name in its internal storage, then return "objectName (objectType1, objectType2)" as the new DisplayRole.

            Software Engineer
            KDAB (UK) Ltd., a KDAB Group company

            1 Reply Last reply
            0
            • G Offline
              G Offline
              giesbert
              wrote on last edited by
              #6

              I assume he uses the widget approach, as he asked for QListWidget. That's why I suggested using a delegate.

              Nokia Certified Qt Specialist.
              Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

              1 Reply Last reply
              0
              • D Offline
                D Offline
                dangelog
                wrote on last edited by
                #7

                Right :) Read between the lines... >:)

                Software Engineer
                KDAB (UK) Ltd., a KDAB Group company

                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