// der Slot für das Laden der Seite
void MainWindow : n_webView_loadFinished( bool ok )
{
int n;
//für die HistoryListe
QWebHistory *meineHistory = ui->webView->history();
n = ui->listWidget->count();
//war das Laden erfolgreich?
if ( ok )
{
{
if ( ( ui->webView->url().toString() ).isEmpty() == false )
{
for ( int i = 0; i <= n; i++ )
// Prüfen ob die geladene Seite schon vorhanden ist
ui->listWidget->findItems( ui->webView->url().toString(), Qt::MatchFixedString );
// wenn die Seite noch nicht vorhanden ist
if ( Qt::MatchFixedString == 8 )
// die URL in das Listenfeld schreiben
ui->listWidget->addItem( ui->webView->url().toString() );
}
else
{
//und auch in das Eingabefeld
adressFeld->setText( ui->webView->url().toString() );
//den Titel setzen
this->setWindowTitle( "Minibrowser - " + ui->webView->title() );
if ( meineHistory->canGoBack() )
ui->action_R_ckw_rts->setEnabled( true );
else
ui->action_R_ckw_rts->setEnabled( false );
if ( meineHistory->canGoForward() )
ui->action_Vorw_rts->setEnabled( true );
else
ui->action_Vorw_rts->setEnabled( false );
}
}
}
}
// der Slot für das Laden der Seite
void MainWindow : n_webView_loadFinished( bool ok )
{
int n;
//für die HistoryListe
QWebHistory *meineHistory = ui->webView->history();
QListWidget *meineListe = new QListWidget( this );
n = ui->listWidget->count();
//war das Laden erfolgreich?
if ( ok )
{
{
if ( ( ui->webView->url().toString() ).isEmpty() == false )
{
for ( int i = 0; i <= n; i++ )
// Prüfen ob die geladene Seite schon vorhanden ist
ui->listWidget->findItems( ui->webView->url().toString(), Qt::MatchFixedString );
// wenn die Seite noch nicht vorhanden ist
if ( Qt::MatchFixedString == 8 )
// die URL in das Listenfeld schreiben
ui->listWidget->addItem( ui->webView->url().toString() );
}
else
{
//und auch in das Eingabefeld
adressFeld->setText( ui->webView->url().toString() );
//den Titel setzen
this->setWindowTitle( "Minibrowser - " + ui->webView->title() );
if ( meineHistory->canGoBack() )
ui->action_R_ckw_rts->setEnabled( true );
else
ui->action_R_ckw_rts->setEnabled( false );
if ( meineHistory->canGoForward() )
ui->action_Vorw_rts->setEnabled( true );
else
ui->action_Vorw_rts->setEnabled( false );
}
}
}
}
To copy to clipboard, switch view to plain text mode
In line 7 you create a new QListWidget. It is created -empty-. Why do you do this when you don't actually use it anywhere? It is a memory leak.
Line 20: Why do you call this method if you do not do anything with the return value? Yes, you are checking to see if you have visited the site already, but then you do nothing with the answer.
Line 22 makes no sense. Qt:: MatchFixedString is a constant with the value 8, so the if clause is always true. And this line is not inside the for() loop because there is no { }. The only statement inside the for() loop is line 20. So the result is that you always add the URL to the list whether it is there or not.
Bookmarks