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. Setting different text when user starts editing QTreeWidgetItem
QtWS25 Last Chance

Setting different text when user starts editing QTreeWidgetItem

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 560 Views
  • 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.
  • Gitesh YeoleG Offline
    Gitesh YeoleG Offline
    Gitesh Yeole
    wrote on last edited by
    #1

    I have a tree which has item named like "abc (id=10, type=xyz)" Tree node is editable. I want user to allow only rename but not modify id and type part. So when user enters in edit mode user should see only "abc" which is editable.

    Any suggestion how to do it.

    RatzzR 1 Reply Last reply
    0
    • Gitesh YeoleG Gitesh Yeole

      I have a tree which has item named like "abc (id=10, type=xyz)" Tree node is editable. I want user to allow only rename but not modify id and type part. So when user enters in edit mode user should see only "abc" which is editable.

      Any suggestion how to do it.

      RatzzR Offline
      RatzzR Offline
      Ratzz
      wrote on last edited by Ratzz
      #2

      @Gitesh-Yeole
      You can get the QString from the index and show only required part of QString (may be using split) . When editing is completed just set back the newname and previous text (--+ (id=10, type=xyz)).

      But I prefer QTableView over QTreeWidget for this.

      --Alles ist gut.

      Gitesh YeoleG 1 Reply Last reply
      0
      • Gitesh YeoleG Offline
        Gitesh YeoleG Offline
        Gitesh Yeole
        wrote on last edited by
        #3

        One way I know is using QItemDelegate just want to check any other simple way

        1 Reply Last reply
        0
        • RatzzR Ratzz

          @Gitesh-Yeole
          You can get the QString from the index and show only required part of QString (may be using split) . When editing is completed just set back the newname and previous text (--+ (id=10, type=xyz)).

          But I prefer QTableView over QTreeWidget for this.

          Gitesh YeoleG Offline
          Gitesh YeoleG Offline
          Gitesh Yeole
          wrote on last edited by
          #4

          @Ratzz Yes this is what I want to do but where should I do as I am not aware of any signal which is emitted just before opening editor

          RatzzR 1 Reply Last reply
          0
          • Gitesh YeoleG Gitesh Yeole

            @Ratzz Yes this is what I want to do but where should I do as I am not aware of any signal which is emitted just before opening editor

            RatzzR Offline
            RatzzR Offline
            Ratzz
            wrote on last edited by
            #5

            @Gitesh-Yeole
            may be https://doc.qt.io/qt-5/qtablewidget.html#itemDoubleClicked ?

            --Alles ist gut.

            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