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 add QSpinBox as QItemDelegate and activate it without doubleclick

[Solved] How to add QSpinBox as QItemDelegate and activate it without doubleclick

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 2.3k 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.
  • H Offline
    H Offline
    Hareen Laks
    wrote on last edited by
    #1

    Hi,

    I added QSpinBox as QItemDelegate to my tableview column using "this example":http://qt-project.org/doc/qt-5.0/qtwidgets/itemviews-spinboxdelegate.html.

    That spinbox only activates when I double click on the column. I need to already activated spinbox when load the dialog.

    Thanks in advance.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      martonmiklos
      wrote on last edited by
      #2

      When I had the same problem I have used the QAbstractItemView::openPersistentEditor method by looping through all the affected fields of my model every model changes. I know that this is not the most elegant way, but I do not know better method right now.

      1 Reply Last reply
      0
      • H Offline
        H Offline
        Hareen Laks
        wrote on last edited by
        #3

        @martonmiklos,

        Thank you very much for your solution.

        It is working fine now.

        And shall I mark this as [solved] or keep it as unsolved? I'm asking this because you told this is not most elegant way.

        Thanks again.

        1 Reply Last reply
        0
        • raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          that's exactly the purpose this method is there for.
          A nicer solution would be to avoid such design at all where you need an persistent editor.
          But as long as you keep the number of editors down you wont notice any performance drawbacks.
          E.g. don't open an persistent editor on every row in a very big table. Use QWidgets instead or redesign your application.

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • H Offline
            H Offline
            Hareen Laks
            wrote on last edited by
            #5

            @ raven-worx,

            Thanks for the reply. I think less than 20 rows won't be a problem. I'll keep your advice in mind.

            Thanks again.

            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