PDA

View Full Version : Why is QUndoStack's cleanChanged signal opposite of QWidget's setWindowModified slot?



wayfaerer
9th March 2012, 23:39
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? :)

wysota
10th March 2012, 00:13
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).

wayfaerer
10th March 2012, 00:30
I agree with you, although in my case (at least right now) it would've been perfect to just connect those! Oh well.