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. Combobox with delete-item buttons at items
Forum Updated to NodeBB v4.3 + New Features

Combobox with delete-item buttons at items

Scheduled Pinned Locked Moved General and Desktop
7 Posts 3 Posters 7.5k 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.
  • R Offline
    R Offline
    real name
    wrote on last edited by
    #1

    (as Qt newbie) i'm searching how to create combobox with delete-item buttons at (mostly) all expanded items
    i planned base it on check box in combobox example presented here http://qt-project.org/forums/viewthread/7079
    but i failed on the fact that createEditor is not called for initially selected item = user must move mouse to another item and back to get createEditor on selected item
    than i wanted call createEditor by myself during item-activated signal but i failed to connect on it because it is emitted by combobox's private part = i haven't pointer to it

    do you have any solution? thanks

    1 Reply Last reply
    0
    • M Offline
      M Offline
      master of disaster
      wrote on last edited by
      #2

      If I understood your problem correctly, you want to remove several items from a QComboBox. I think the best solution would be this one:

      @
      combobox.removeItem(combobox.currentIndex());
      @

      With this code, you would delete the entry that is currently active (shown in the non-expanded field).

      1 Reply Last reply
      0
      • R Offline
        R Offline
        real name
        wrote on last edited by
        #3

        i want every item will have except standard text also (right-side) image, after click to image/picture/icon it will delete item (= removeItem)
        problem is now to handle that click to image (click to text has to be handled standard way = item selection)

        1 Reply Last reply
        0
        • M Offline
          M Offline
          master of disaster
          wrote on last edited by
          #4

          Not that easy. As you can see in the class reference, QComboBox provides these signals:
          @
          void activated ( int index )
          void activated ( const QString & text )
          void currentIndexChanged ( int index )
          void currentIndexChanged ( const QString & text )
          void editTextChanged ( const QString & text )
          void highlighted ( int index )
          void highlighted ( const QString & text )
          @

          Then, it inherits one from QWidget
          @
          void customContextMenuRequested ( const QPoint & pos )
          @

          and one from QObject
          @
          void destroyed ( QObject * obj = 0 )
          @

          There is not a single one to handle mouse clicks. It will be difficult to catch those; it would be easier to make a "delete" button or a "delete" menu entry.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            ArcNexus
            wrote on last edited by
            #5

            I think you can overwrite Paint metod and add "add,edit and delete" items QPicture type After you can connect your items Signal Click from QPicture with your Slots for add, edit and delete items.

            But I think it's not easy..... I don't have tested it, but can function

            When we are one, we win

            1 Reply Last reply
            0
            • R Offline
              R Offline
              real name
              wrote on last edited by
              #6

              [quote author="ArcNexus" date="1356477291"]I think you can overwrite Paint metod and add "add,edit and delete" items QPicture type[/quote]
              i see no problem to overwrite QItemDelegate::paint
              but what does it mean 'add "add,edit and delete" items QPicture type'? (remember that QItemDelegate::createEditor is not called for actual item, where else i can do it?)

              p.s. today i found that overwriting QItemDelegate::event it is not called at all

              1 Reply Last reply
              0
              • A Offline
                A Offline
                ArcNexus
                wrote on last edited by
                #7

                [quote author="real name" date="1357133282"]
                i see no problem to overwrite QItemDelegate::paint
                but what does it mean 'add "add,edit and delete" items QPicture type'?[/quote]

                Yes, when I say Add,edit and delete i refer to QPicture. But I have not tested it. however i think it should work if you overwrite methods but its not easy.

                When we are one, we win

                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