Page 2 of 2 FirstFirst 12
Results 21 to 26 of 26

Thread: display images in qt from text file

  1. #21
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: display images in qt from text file

    Quote Originally Posted by iswaryasenthilkumar View Post
    i calculated sir bt its not properly working for evry 5th minute..
    There are 300 seconds in a 5 minute period, so not sure why you're modding the seconds by 5 and expecting that to equate to 5 minutes. Also, I don't know how your section of code is executed, but even if you change to:

    Qt Code:
    1. if ((time.second() % 300) == 0)
    To copy to clipboard, switch view to plain text mode 
    Your code would have to execute exactly on every 5th minute or else you'd miss the window until the next 5 minute (300 seconds) interval. You really should use a QTimer here IMHO.
    Last edited by jefftee; 11th December 2014 at 05:45.

  2. #22
    Join Date
    Nov 2014
    Location
    Chennai
    Posts
    160
    Thanks
    65
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: display images in qt from text file

    help me sir...


    Added after 6 minutes:


    ya this only i putd sir bt my problem is remote folder displaying only two images of evry 5 th minute,its not dispalying remaining images in remote folder.. can you pls check my code and rectify my problem plsss.
    my coding
    Qt Code:
    1. void Widget::ReadImagesfromlocalFolder()
    2. {
    3.  
    4. QString filePath1("/home/ishwarya/displayimages/configfile");
    5. QString filePath2("/home/ishwarya/displayimages/local");
    6. QString sortedimagesfilenameslist="temp.txt";
    7. dir.cd(filePath1);
    8. QFile file;
    9. file.setFileName(dir.absoluteFilePath(sortedimagesfilenameslist));
    10. file.open(QIODevice::ReadOnly);
    11. QTextStream stream( &file );
    12. QString imagefilename[100];
    13. for(int i=0;i<31;i++)
    14. {
    15. showFullScreen();
    16. activateWindow();
    17. imagefilename[i]= stream.readLine();
    18. qDebug()<<"local:"<<imagefilename[i];
    19. dir.cd(filePath2);
    20. QFile file1;
    21. file1.setFileName(dir.absoluteFilePath(imagefilename[i]));
    22. QImage ImageToLoad;
    23. ImageToLoad.load(dir.absoluteFilePath(imagefilename[i]));
    24. QLabel *label = new QLabel(this);
    25. label->setPixmap(QPixmap::fromImage(ImageToLoad.scaled(900,900,Qt::KeepAspectRatio,Qt::FastTransformation)));
    26. label->showFullScreen();
    27. delay();
    28.  
    29. }
    30.  
    31. }
    32. void Widget::ReadImagesfromRemoteFolder()
    33. {
    34. int j=0;
    35. QString filePath1("/home/ishwarya/displayimages/configfile");
    36. QString filePath2("/home/ishwarya/displayimages/remote");
    37. QString sortedimagesfilenameslist="tempp.txt";
    38. dir.cd(filePath1);
    39. QFile file;
    40. file.setFileName(dir.absoluteFilePath(sortedimagesfilenameslist));
    41. file.open(QIODevice::ReadOnly);
    42. QTextStream stream( &file );
    43. QString imagefilename[24];
    44. for(j=0;j<24;j++)
    45. {
    46. showFullScreen();
    47. activateWindow();
    48. imagefilename[j]= stream.readLine();
    49. qDebug()<<"remote:"<<imagefilename[j];
    50. dir.cd(filePath2);
    51. QFile file1;
    52. file1.setFileName(dir.absoluteFilePath(imagefilename[j]));
    53. QImage ImageToLoad;
    54. ImageToLoad.load(dir.absoluteFilePath(imagefilename[j]));
    55. QLabel *label = new QLabel(this);
    56. label->setPixmap(QPixmap::fromImage(ImageToLoad.scaled(900,900,Qt::KeepAspectRatio,Qt::FastTransformation)));
    57. label->showFullScreen();
    58. delay();
    59. ReadImagesfromlocalFolder();
    60. }
    61. }
    62.  
    63. void Widget::delay()
    64. {
    65. QTime time = QTime::currentTime();
    66.  
    67. if((time.second() % 300 ) == 0)
    68. {
    69.  
    70. ReadImagesfromRemoteFolder();
    71.  
    72. }
    73.  
    74.  
    75. if(checklocalseconds=="local=10seconds")
    76. {
    77. sleepTime = QTime::currentTime().addSecs(10);
    78. while(QTime::currentTime() < sleepTime);
    79. qDebug()<<"check";
    80. QApplication::processEvents(QEventLoop::AllEvents,1000);
    81. }
    82.  
    83. }
    To copy to clipboard, switch view to plain text mode 
    Quote Originally Posted by jthomps View Post
    There are 300 seconds in a minute, so not sure why you're modding the seconds by 5 and expecting that to equate to 5 minutes. Also, I don't know how your section of code is executed, but even if you change to:

    Qt Code:
    1. if ((time.seconds() % 300) == 0)
    To copy to clipboard, switch view to plain text mode 
    Your code would have to execute exactly on every 5th minute or else you'd miss the window until the next 5 minute (300 seconds) interval. You really should use a QTimer here IMHO.
    Last edited by wysota; 11th December 2014 at 08:54. Reason: missing [code] tags

  3. #23
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: display images in qt from text file

    Quote Originally Posted by iswaryasenthilkumar View Post
    help me sir...
    I have attempted to help you, however, you have ignored everything I have said. Ultimately, you are trying to brute force a solution when Qt provides a much more flexible and easy to implement event driven mechanism using QTimer and signals and slots.

    You really need to spend some time understanding Qt and reading the documentation... For example, I just read the documentation for QTime::second() and it returns the seconds portion of the QTime, which is a value between 0-59, so you won't succeed with that approach.

    If I understand what you are trying to accomplish, and it's very hard to figure it out IMHO, you want to display a local image every 10 seconds, except for every 5th minute (300 seconds), you want to display a remote image. If that is close to what you are trying to achieve, then you should:


    1. Use QTime and QTime::start() during your program's initialization.
    2. Use a QTimer with a 10 second interval and connect the QTimer timeout() signal to a slot in your program.
    3. In the slot above you can use QTime::elapsed() on the QTime variable you started in step 1.
    4. Divide the elapsed milliseconds by 1,000 to get the number of seconds.
    5. If seconds >= 300, display your remote image and use QTime::restart() to restart the QTime again.
    6. If seconds < 300, display a local image.


    Your slot will then be invoked again after 10 seconds until you stop the QTimer during your program's termination. If this doesn't help you, I'm afraid I can't help you...

  4. #24
    Join Date
    Nov 2014
    Location
    Chennai
    Posts
    160
    Thanks
    65
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: display images in qt from text file

    nt like that sir..am a fresher sir,, i dnt knw hw to do... am nw only learning QT..

  5. #25
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: display images in qt from text file

    Quote Originally Posted by iswaryasenthilkumar View Post
    nt like that sir..am a fresher sir,, i dnt knw hw to do... am nw only learning QT..
    So learn instead of taking on tasks you have not a slightest idea how to solve. Qt is not your problem, your problem is inability to come up with an algorithm which will solve the task at hand. Jthomps had a lot of patience for you but you clearly indicate no interest in investing your time to learn anything so I am not surprised he got fed up with your slideshow. If you want to learn then start with something simple and when you gain experience you can work on more complex code. If you are expecting to get a ready working solution, then people here are smart enough not to give it to you. And please finally stop this trash-talking, if you are unable to formulate a proper sentence in English then it means you pay no respect to people trying to help you.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #26
    Join Date
    Nov 2014
    Location
    Chennai
    Posts
    160
    Thanks
    65
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: display images in qt from text file

    K sir..I will try to improve my knowledge in Algorithm

Similar Threads

  1. Replies: 1
    Last Post: 31st October 2014, 07:32
  2. Replies: 2
    Last Post: 22nd September 2012, 01:18
  3. How to display text from a file to a text browser
    By ironmantis7x in forum Newbie
    Replies: 11
    Last Post: 14th June 2012, 15:23
  4. Saving Text and Images as a file
    By rleojoseph in forum Qt Programming
    Replies: 2
    Last Post: 15th February 2011, 09:15
  5. Widget to display images and text ?
    By probine in forum Qt Tools
    Replies: 4
    Last Post: 9th October 2006, 20:49

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.