if ( doc.contains ( doc& ) == file ){// this line generate err
if ( doc.contains ( doc& ) == file ){// this line generate err
To copy to clipboard, switch view to plain text mode
This line makes no sense, as someone else pointed out. Even if you got the syntax right, it still makes no sense.
Assuming what you want is
if( doc.at(i) == file )
if( doc.at(i) == file )
To copy to clipboard, switch view to plain text mode
then what that line says is to compare a "FilmDoc" object (that's what is getting retrieved from the QList using the at() method) to a char * string. If your FilmDoc class doesn't have a
bool operator==( const char * ) const;
bool operator==( const char * ) const;
To copy to clipboard, switch view to plain text mode
method, then this is what is generating your compile error.
You probably want code that looks something like this:
void FilmApp::openDocumentFile (const char *file)
{
statusBar ()->message (tr ("Opening file..."));
QList <FilmDoc> doc
= *pDocList;
// if this might help function has to check if file is already opened
// and if yes then setFocus to opened view
for ( int i = 0; i < doc.size (); ++i ) {
const FileDoc & fileDoc = doc.at( i );
if (fileDoc.name() == file ) {
// But now this line will generate an error, because QList<T> doesn't have a "firstView()" method.
// You probably mean: FilmView * view = fileDoc.firstView() instead
FilmView * view = doc->firstView ();
view->setFocus ();
return;
}
}
...
}
void FilmApp::openDocumentFile (const char *file)
{
statusBar ()->message (tr ("Opening file..."));
QList <FilmDoc> doc = *pDocList;
// if this might help function has to check if file is already opened
// and if yes then setFocus to opened view
for ( int i = 0; i < doc.size (); ++i ) {
const FileDoc & fileDoc = doc.at( i );
if (fileDoc.name() == file ) {
// But now this line will generate an error, because QList<T> doesn't have a "firstView()" method.
// You probably mean: FilmView * view = fileDoc.firstView() instead
FilmView * view = doc->firstView ();
view->setFocus ();
return;
}
}
...
}
To copy to clipboard, switch view to plain text mode
Added after 7 minutes:
Sorry, I meant "FilmDoc", not "FileDoc" in line 10. Got confused comparing films and files.
Bookmarks