Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Question_QListWidget
Qt 6.11 is out! See what's new in the release blog

Question_QListWidget

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 518 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cprogcoder
    wrote on last edited by
    #1

    [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%)

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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 .

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved