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. QUndoStack set memory limit to commands

QUndoStack set memory limit to commands

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

    Hi,
    I have QUndoStack to control my commands and everything is super, except limit to commands. Standard QUndoStack allows to set limit by number of commands, but I want to control commands memory using, at least as QCache with commands weight . Because, I have plots with delete and add commands, so it may take up a lot of memory.
    Main question: in which way it would better to do - try to re-implement QUndoStack or maybe using another structure.
    I saw similar question, but without answer:
    https://forum.qt.io/topic/59506/remove-first-qundocommand-from-qundostack

    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      zonman
      wrote on last edited by
      #2

      Okay, I implemented my own stack. Just add command setMaxWeight in bytes and add check in push() method to ensure enough weight available. If currentWeight is greater maxWeight, I started to delete command from bottom of the stack.
      I used another abstract class for command, that inherits QUndoCOmmand and have custom virtual method:
      size_t wieght() const;
      And inherited my commands by that class

      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