Question_QListWidget



  • [0_1505661794686_Question_QListwidget.doc](Uploading 100%) I have a question about using the QlistWidget Function where to use it to check if it is listed before and if not it should written into the listwdget.
    I have prepared some code but it doesnt work properly. Can someone look and correct if possible ?

    Thanks in advance,

    The part of the code (also included as txt file)

    //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);
    }
    }
    }

    //die Fortschrittsanzeige ausblenden
    fortschrittBalken->setVisible(false);
    //den Text ändern
    fortschrittLabel->setText("Seite geladen");

    ---------------------------------------------------------[0_1505661808217_Question_QListwidget.txt](Uploading 100%) [0_1505661838756_Question_QListwidget.txt](Uploading 100%)


  • Lifetime Qt Champion

    Hi,

    First thing: why are you creating a new QListWidget every time n_webView_loadFinished is called ?
    Second: if (Qt::MatchFixedString ==8) doesn't make any sense, you should check the return result of findItems .


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.