Hello,
I'm building (or rather playing with) a Qt 4.7 app which basically consists of a window that contains a menu bar, a tab widget and a status bar. Each tab in the tab widgets contains a plain text editor. So basically, it's a tabbed plain text editor 
Until now, I've managed to get it to create/open/save/close files, however, I haven't been able to change the tab text when the contents of the QPlainTextEdit change. It's simple when I open/save the file, but I don't know how to do it otherwise.
Any ideas?
In a SDI app I would normally do something like:
connect(textEdit->document(), SIGNAL(contentsChanged()), this, SLOT(documentWasModified()));
connect(textEdit->document(), SIGNAL(contentsChanged()), this, SLOT(documentWasModified()));
To copy to clipboard, switch view to plain text mode
but in this case, the text editor is no longer the central widget.
I've tried (in the newFile method):
EditorTab *editorTab = new EditorTab;
int tabIndex = tabWidget->addTab(
editorTab,
editorTab->currentTitle
);
tabWidget->setCurrentIndex(tabIndex);
connect(
editorTab->document(),
SIGNAL(contentsChanged()),
this,
SLOT(documentWasModified(tabIndex))
);
editorTab->setFocus();
EditorTab *editorTab = new EditorTab;
int tabIndex = tabWidget->addTab(
editorTab,
editorTab->currentTitle
);
tabWidget->setCurrentIndex(tabIndex);
connect(
editorTab->document(),
SIGNAL(contentsChanged()),
this,
SLOT(documentWasModified(tabIndex))
);
editorTab->setFocus();
To copy to clipboard, switch view to plain text mode
documentWasModified is:
qDebug("Tab %d changed", tabIndex);
tabWidget->setTabText(tabIndex, "CHANGED");
qDebug("Tab %d changed", tabIndex);
tabWidget->setTabText(tabIndex, "CHANGED");
To copy to clipboard, switch view to plain text mode
And the result is
Object::connect: No such slot MainWindow::documentWasModified(tabIndex) in ..\tabbedtextedit\mainwindow.cpp:85
Object::connect: No such slot MainWindow::documentWasModified(tabIndex) in ..\tabbedtextedit\mainwindow.cpp:85
To copy to clipboard, switch view to plain text mode
Bookmarks