Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. QlistWidget
Forum Updated to NodeBB v4.3 + New Features

QlistWidget

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
2 Posts 2 Posters 592 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.
  • E Offline
    E Offline
    EgyProg
    wrote on last edited by
    #1

    hi everyone i need a way to read a text file in qlistwidget i use this code
    QFile file(thefilename);
    if(file.open( QIODevice::ReadOnly))
    {
    QString line = "";
    while(!file.atEnd())
    {
    line = file.readLine();
    ui->listWidget->addItem(line);
    }
    file.close();
    }

    its working but it is show the words which in the file in the list widget 3 times i mean if i have 2 words i find it will repeat the 2 words 3 times in the list so can anyone help me to solve this problem

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

      Hi,

      Might be a silly question but are you sure that this function is not called several times with the same file ?

      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