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. QUndoView::QListView how to disable some item?
Qt 6.11 is out! See what's new in the release blog

QUndoView::QListView how to disable some item?

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 726 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.
  • N Offline
    N Offline
    nen777w
    wrote on last edited by
    #1

    I use QUndoView which is inherited from QListView. In some cases, I need to disable set of commands from the list (i.e. make it unselectable by user), how to do that?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      There's no easy way to do that as QUndoView uses a custom model on top of QUndoStack/QUndoGroup.

      Can you explain your use case ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • N Offline
        N Offline
        nen777w
        wrote on last edited by nen777w
        #3

        When the user works with the document, some operations may take a long time and in this case, these operation run in separate threads (for avoiding main GUI thread freeze).

        Also, these operations apply to some object (for example layer) which is also can be added/remove by the user.
        So Undo stack looks the following:

        <some command>
        <add layer 0>
        <draw on layer 0>
        <draw on layer 0> <-- for example user select this command and then run processing (which is run in separate threads).
        <remove layer 0>

        If during the processing user select command <remove layer 0> (or command before <add layer 0>) it may lead to an application crash, because "layer 0" is no longer exist.

        This is why I need to disable (make unselectable) some commands (<add layer 0> and commands above & <remove layer 0> and commands bellow) from the stack when the operation is performed.
        I can easily do that with actions but unfortunately, I do not find this possibility in QUndoView.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          And I don't think you are going to be able to do that with QUndoView as it is currently implemented.

          You should check its implementation and create your own View/Model combo that fits your need. This is going to be faster.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          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