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. [Solved]Runtime Bug in Image Slidshow Application
Forum Update on Monday, May 27th 2025

[Solved]Runtime Bug in Image Slidshow Application

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 1.3k Views
  • 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.
  • H Offline
    H Offline
    Haresh
    wrote on 25 Aug 2015, 07:12 last edited by Haresh
    #1

    hello everyone
    I have created a gui application for slide show of images consisting of a push-button to select a directory from file system and a label to display images at interval of 5 seconds.
    It compiles and runs fine if I use it for a single directory but if it is running a slide show and I select another directory then it displays images of both directories.
    so anyone can please help me out of this???

    1 Reply Last reply
    0
    • H Offline
      H Offline
      Huulivoide
      wrote on 25 Aug 2015, 07:46 last edited by
      #2

      I think you have forgotten to empty the list of image files before you build
      the list from the new directory. But without any code it hard to say for sure.

      1 Reply Last reply
      0
      • H Offline
        H Offline
        Haresh
        wrote on 25 Aug 2015, 08:43 last edited by
        #3

        I have clear the stringlist before reusing it.

        void MainWindow::on_pushButton_clicked()
        {
        int index=0;
        QString DirectryPath,ImagePath;
        QStringList SetFilter,FileList;
        QDir DirName;

        FileList.clear();
        
        DirectryPath=QFileDialog::getExistingDirectory(this,tr("Select Folder"),"/home",QFileDialog::ShowDirsOnly|QFileDialog::DontResolveSymlinks);
        DirectryPath=DirectryPath +'/';
        qDebug() << DirectryPath;
        
        DirName=DirectryPath;
        qDebug()<<DirName;
        
        SetFilter<<"*.jpg"<<"*.jpeg"<<"*.png";
        DirName.setNameFilters(SetFilter);
        
        FileList=DirName.entryList(QDir::Files,QDir::NoSort);
        
        qDebug() << FileList;
        qDebug()<<FileList.size();
        
        while(index<FileList.count())
        {
            ImagePath=DirectryPath+FileList[index];
            qDebug()<<ImagePath;
            QImage image(ImagePath);
            qDebug()<<image;
            ui->label_pic->setPixmap(QPixmap::fromImage(image));
            ui->label_pic->setScaledContents(true);
            index++;
            delay();
        }
        

        ui->label_pic->setText(tr("No More Images Avalable"));

        }

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 25 Aug 2015, 20:12 last edited by SGaist
          #4

          Hi,

          You might be having your loop running twice. You should modify your architecture and rather use a QTimer for your 5 second interval. Start it once you created your list and stop it before you create it.

          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
          0
          • H Offline
            H Offline
            Haresh
            wrote on 28 Aug 2015, 05:58 last edited by Haresh
            #5

            hello,
            It is now working as I wanted so thank you for your help.
            But you said my loop is running twice so is there any another way I can stop the previous loop from executing when same signal is generated again.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 28 Aug 2015, 22:24 last edited by
              #6

              Yes, rather than use a while loop like that, use a QTimer

              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
              0

              1/6

              25 Aug 2015, 07:12

              • Login

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