PDA

View Full Version : check modified for tab widgets



sandytang
8th July 2011, 00:02
HI,
I have a main window with tabWidget that contains multiple tabs.
tabs are widgets like QTextEdit or user define graphic widgets.
I have been having hard time to figure out how to detect changes from those tabs.
I need to detect changes.
so that i can change the tab name to file.txt* when the changes are unsaved. (need the asterisk).
and ask user if they want to save before close.

From what i researched, changes can be found by
QWdiget::isWindowModified()
or the QUndoGroup/QUndoStack frame works.


i tried
if(QWidget::isWindowModified())
{
QMessageBox msgBox;
msgBox.setText("The document has been modified.");
msgBox.exec();
}
but it does not seem to work.

regarding to the undo frame work. Seems like it has to hard coded every actions/commands for undo and redo.
in other words, have to implement the actions that cause the undo to be enable.
is there an easy way to check isModified for Widgets?

tomkonikkara
9th July 2011, 15:40
to detect tabchange do this: (assume *tabWidget is an object QTabwidget)
signal for detecting tab change : tabWidget->currentChanged()
To determine to which tab, it is changed, use: tabWidget->currentIndex()