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. Clicking in QTreeWidget item while already editing reopens the editor.
Forum Updated to NodeBB v4.3 + New Features

Clicking in QTreeWidget item while already editing reopens the editor.

Scheduled Pinned Locked Moved General and Desktop
7 Posts 2 Posters 6.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.
  • M Offline
    M Offline
    mfeemster
    wrote on last edited by
    #1

    This is a very simple problem that is easy to repro. It might a bug, but I'll try to describe what I'm looking for first.

    I have a QTreeWidget and I want the following standard behavior:

    Single click an item selects the item.
    Single click an already selected item allows for editing the item.
    Double click takes other special action.

    If I single click an already selected selected QTreeWidgetItem, the line edit opens as it should.

    However, if I click inside that line edit, it closes, then re-opens the line editor again with all of the text selected, which is not what I want.

    If I click inside of an already opened line edit, it should remain open, and de-select any selected text. This is standard behavior for edit controls.

    This seems like it would be very common, standard behavior for most usage of QTreeWidget, so I'm hesitant to call it a bug. But I've tried everything I can possibly think of an nothing will work. Can anyone shed some light? Thanks.

    Using a custom build of Qt5 on Windows 7, x64.

    github.com/mfeemster/fractorium/wiki

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

      [quote author="mfeemster" date="1371439525"]
      This seems like it would be very common, standard behavior for most usage of QTreeWidget, so I'm hesitant to call it a bug.[/quote]

      I wouldn't say that this is default behavior in good GUI design manners.

      But without posting any of your code nobody will be able to help you...
      Especially the part where you start editing on an index on the click of an already selected index will be interesting.

      --- 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
      • M Offline
        M Offline
        mfeemster
        wrote on last edited by
        #3

        Perhaps I wasn't clear. I am saying that the current Qt behavior for the edit trigger 'SelectedClicked' is not consistent with the standard behavior of edit controls.

        For an example of the standard behavior I am after, try renaming a file on your system by clicking on it, then clicking again. An edit box will open up. When you click in that edit box, it positions the cursor for you to type. That is what I'm after, yet Qt does something quite different.

        Repro steps and code:

        1. Place a tree view with one column on your window via Qt Designer and name it TestTree.
        2. For the edit triggers, set 'SelectedClicked', and uncheck the others.
        3. Construct some items with the following code and run.
        4. Click one of the child items, then click it again. An edit box will open up. When you click in the edit box, instead of positioning the cursor, it closes it, re-opens it, then selects all of the text. That is not what I want it to do.

        [CODE]
        QTreeWidget* tree = ui.TestTree;
        QTreeWidgetItem* topItem = new QTreeWidgetItem(tree);
        topItem->setText(0, "top text");

        QTreeWidgetItem* childItem1 = new QTreeWidgetItem(topItem);
        childItem1->setFlags(Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable);
        childItem1->setText(0, "child text 1");

        QTreeWidgetItem* childItem2 = new QTreeWidgetItem(topItem);
        childItem2->setFlags(Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable);
        childItem2->setText(0, "child text 2");
        [/CODE]

        Any insight is much appreciated. Thanks.

        github.com/mfeemster/fractorium/wiki

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

          i can't reproduce the issue you described.

          When an item is opened for editing the editor gets the focus set immediately. If it looses the focus it will get closed. Maybe you change the focus somewhere?
          Or there is some other code which you aren't posted which causes this misbehavior.

          This code works as expected:
          @
          QTreeWidget* tree = new QTreeWidget;
          tree->setEditTriggers( QAbstractItemView::SelectedClicked );

          QTreeWidgetItem* topItem = new QTreeWidgetItem(tree);
          topItem->setText(0, "top text");
          
          QTreeWidgetItem* childItem1 = new QTreeWidgetItem(topItem);
          childItem1->setFlags(Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable);
          childItem1->setText(0, "child text 1");
          
          QTreeWidgetItem* childItem2 = new QTreeWidgetItem(topItem);
          childItem2->setFlags(Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable);
          childItem2->setText(0, "child text 2");
          

          @

          --- 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
          • M Offline
            M Offline
            mfeemster
            wrote on last edited by
            #5

            [quote author="raven-worx" date="1371536186"]If it looses the focus it will get closed. Maybe you change the focus somewhere?
            [/quote]

            No, I don't change or lose the focus. In order to repro:

            Click the item to select it.
            Click the item again to edit.
            Do not move the mouse at all, so the editor remains open and has focus.
            Click the editor again. It closes, then opens again with all of the text selected.

            If it still doesn't repro for you, I'll assume I pulled code that has a bug in it. I'll try pulling fresh from qt5stable to see if perhaps it's been fixed. Let me know, thanks.

            github.com/mfeemster/fractorium/wiki

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

              yes... still not reproducible ;)

              --- 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
              • M Offline
                M Offline
                mfeemster
                wrote on last edited by
                #7

                Thanks for checking on that. I will do a fresh pull from qt5stable, rebuild and see where it gets me. I'll post here to confirm if it's fixed.

                Edit: It was fixed. Thanks.

                github.com/mfeemster/fractorium/wiki

                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