I have a tab system using http://doc.qt.io/qt-5/qtquick-custom...idget-qml.html, in which one tab is a configuration tab, once the user has modified something I want to warn them if they try to change tabs, gving them the option to exit without applying changes. Is there a proper way to do this without changing the tabWidget code?

My idea is to add a boolean property to the tabWidget and the proper tab to set it when something has been modified and then on onClicked check if it is set to not change the tab. Is this the proper way?

something like
Qt Code:
  1. property bool canChangeIndex: false
  2. // ... tabWidget code
  3. // on the onClicked signal
  4.  
  5. onClicked: if (canChangeIndex) tabWidget.current = index
To copy to clipboard, switch view to plain text mode