Results 1 to 3 of 3

Thread: Why is QUndoStack's cleanChanged signal opposite of QWidget's setWindowModified slot?

  1. #1
    Join Date
    Jan 2012
    Posts
    66
    Thanks
    20
    Thanked 2 Times in 2 Posts
    Platforms
    Windows

    Default Why is QUndoStack's cleanChanged signal opposite of QWidget's setWindowModified slot?

    I'd like to use QUndoStack's cleanChanged(bool) signal to control QWidget's setWindowModified(bool) slot, but they seem to be the opposite: i.e., cleanChanged is true when the stack is clean, but setWindowModified(true) makes the window modified/dirty.

    Is there anything I can do short of making a new method in my QMainWindow just to reverse the boolean? Or am I missing something really obvious?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Why is QUndoStack's cleanChanged signal opposite of QWidget's setWindowModified s

    The simplest way is to have a dedicated slot. Modified flag of the window might change because of other actions besides the stack getting clean and the stack can get clean because of other actions than just undoing everything you have done so far so it seems a good approach to have a dedicated slot that will check all the conditions and then based on the result will manually clean the stack and clear the modification flag. Auto-relating those two separate mechanisms might not always be a good idea (e.g. saving a document should clear the modified flag but not necessarily should clean the stack).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    wayfaerer (10th March 2012)

  4. #3
    Join Date
    Jan 2012
    Posts
    66
    Thanks
    20
    Thanked 2 Times in 2 Posts
    Platforms
    Windows

    Default Re: Why is QUndoStack's cleanChanged signal opposite of QWidget's setWindowModified s

    I agree with you, although in my case (at least right now) it would've been perfect to just connect those! Oh well.

Similar Threads

  1. How to connect a slot(QWidget*) with signal(clicked())
    By revellix in forum Qt Programming
    Replies: 10
    Last Post: 5th August 2011, 16:19
  2. Replies: 2
    Last Post: 3rd May 2011, 20:22
  3. Replies: 0
    Last Post: 3rd August 2010, 11:47
  4. Title Bar Change setWindowModified
    By KaptainKarl in forum Qt Programming
    Replies: 2
    Last Post: 15th February 2007, 17:03
  5. signal slot conection using a string, not a SLOT
    By rianquinn in forum Qt Programming
    Replies: 6
    Last Post: 5th February 2006, 18:52

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.