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. Add widget right aligned to a QTableWidget cell
Forum Updated to NodeBB v4.3 + New Features

Add widget right aligned to a QTableWidget cell

Scheduled Pinned Locked Moved Solved General and Desktop
46 Posts 4 Posters 8.8k 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 hbatalha

    @JonB said in Add widget right aligned to a QTableWidget cell:

    Beware that this topic is not about replacing setCellWidget(), the one about setCellWidget() is still open.

    this is one hell of a lot of code to add for a delegate approach if setCellWidget() would have done the job?

    setCellWidget() is just awful when you have a chance of using a delegate instead. Since I discovered that I can use a delegate instead, having a setCellWidget has become very unsettling for me.

    JonBJ Online
    JonBJ Online
    JonB
    wrote on last edited by JonB
    #41

    @hbatalha
    Thanks, I did wonder whether it was a different topic, but didn't try to go find it.

    Your sentiments must warm the cockles of @VRonin's heart ;-) But for those of us who value writing as little code as possble when there is built-in stuff it's not such good news. I do respect why delegates are a better choice, shame there is so much code to write.

    @VRonin should "publish" a library/class, QStyledItemWidgetDelegate, perhaps based on the code of his referred to in his last post, which does everything one might want from setCellWidget but in a delegate-y way, for everyone to use :) [Also, he should try to keep it down to, say, 10 lines...]

    VRoninV H 2 Replies Last reply
    0
    • JonBJ JonB

      @hbatalha
      Thanks, I did wonder whether it was a different topic, but didn't try to go find it.

      Your sentiments must warm the cockles of @VRonin's heart ;-) But for those of us who value writing as little code as possble when there is built-in stuff it's not such good news. I do respect why delegates are a better choice, shame there is so much code to write.

      @VRonin should "publish" a library/class, QStyledItemWidgetDelegate, perhaps based on the code of his referred to in his last post, which does everything one might want from setCellWidget but in a delegate-y way, for everyone to use :) [Also, he should try to keep it down to, say, 10 lines...]

      VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #42

      @JonB said in Add widget right aligned to a QTableWidget cell:

      Also, he should try to keep it down to, say, 10 lines...

      ahahah!

      should "publish" a library/class, QStyledItemWidgetDelegate

      Already on my TODO list

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      H 1 Reply Last reply
      1
      • JonBJ JonB

        @hbatalha
        Thanks, I did wonder whether it was a different topic, but didn't try to go find it.

        Your sentiments must warm the cockles of @VRonin's heart ;-) But for those of us who value writing as little code as possble when there is built-in stuff it's not such good news. I do respect why delegates are a better choice, shame there is so much code to write.

        @VRonin should "publish" a library/class, QStyledItemWidgetDelegate, perhaps based on the code of his referred to in his last post, which does everything one might want from setCellWidget but in a delegate-y way, for everyone to use :) [Also, he should try to keep it down to, say, 10 lines...]

        H Offline
        H Offline
        hbatalha
        wrote on last edited by hbatalha
        #43

        @JonB said in Add widget right aligned to a QTableWidget cell:

        @VRonin should "publish" a library/class, QStyledItemWidgetDelegate, perhaps based on the code of his referred to in his last post, which does everything one might want from setCellWidget but in a delegate-y way, for everyone to use :) [Also, he should try to keep it down to, say, 10 lines...]

        I was about to say that. Maybe propose the library to the Qt team to add to the official release(if that's how it is done)

        1 Reply Last reply
        0
        • VRoninV VRonin

          @JonB said in Add widget right aligned to a QTableWidget cell:

          Also, he should try to keep it down to, say, 10 lines...

          ahahah!

          should "publish" a library/class, QStyledItemWidgetDelegate

          Already on my TODO list

          H Offline
          H Offline
          hbatalha
          wrote on last edited by hbatalha
          #44

          @VRonin I have a simple question: is it possible to use setItemDelegateForRow and setItemDelegateForRow at the same view(same row)?

          VRoninV 1 Reply Last reply
          0
          • H hbatalha

            @VRonin I have a simple question: is it possible to use setItemDelegateForRow and setItemDelegateForRow at the same view(same row)?

            VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on last edited by
            #45

            @hbatalha said in Add widget right aligned to a QTableWidget cell:

            @VRonin I have a simple question: is it possible to use setItemDelegateForRow and setItemDelegateForRow at the same view(same row)?

            I assume you mean setItemDelegateForRow and setItemDelegateForColumn.
            from https://doc.qt.io/qt-5/qabstractitemview.html#setItemDelegateForRow

            Note: If a delegate has been assigned to both a row and a column, the row delegate will take precedence and manage the intersecting cell index.

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            H 1 Reply Last reply
            2
            • VRoninV VRonin

              @hbatalha said in Add widget right aligned to a QTableWidget cell:

              @VRonin I have a simple question: is it possible to use setItemDelegateForRow and setItemDelegateForRow at the same view(same row)?

              I assume you mean setItemDelegateForRow and setItemDelegateForColumn.
              from https://doc.qt.io/qt-5/qabstractitemview.html#setItemDelegateForRow

              Note: If a delegate has been assigned to both a row and a column, the row delegate will take precedence and manage the intersecting cell index.

              H Offline
              H Offline
              hbatalha
              wrote on last edited by
              #46

              @VRonin said in Add widget right aligned to a QTableWidget cell:

              I assume you mean setItemDelegateForRow and setItemDelegateForColumn.

              yes, I copied and pasted n forgot to modify before submitting.

              Thanks

              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