display images in qt from text file
i have a text fileit contains set of jpeg images sorted in linux.this images should display in qtwidget in one after another for every 10 seconds based on timer concept ,can any one help me to do this.:confused::(
my text file below
/home/ishwarya/displayimages/local/temp.txt
total 284
-rw-rw-r-- 1 ishwarya ishwarya 0 Dec 4 18:44 temp.txt
-rw-rw-r-- 1 ishwarya ishwarya 6483 Dec 3 15:27 10.jpeg
-rw-rw-r-- 1 ishwarya ishwarya 10069 Dec 3 15:25 27.jpeg
-rw-rw-r-- 1 ishwarya ishwarya 8096 Dec 3 15:24 26.jpeg
-rw-rw-r-- 1 ishwarya ishwarya 17116 Dec 3 15:24 25.jpeg
-rw-rw-r-- 1 ishwarya ishwarya 10017 Dec 3 15:24 24.jpeg
-rw-rw-r-- 1 ishwarya ishwarya 4912 Dec 3 15:24 23.jpeg
-rw-rw-r-- 1 ishwarya ishwarya 4932 Dec 3 15:24 22.jpeg
-rw-rw-r-- 1 ishwarya ishwarya 9031 Dec 3 15:24 21.jpeg
-rw-rw-r-- 1 ishwarya ishwarya 5078 Dec 3 15:23 20.jpeg
-rw-rw-r-- 1 ishwarya ishwarya 5741 Dec 3 15:23 19.jpeg
-rw-rw-r-- 1 ishwarya ishwarya 9132 Dec 3 15:23 18.jpeg
-rw-rw-r-- 1 ishwarya ishwarya 11094 Dec 3 15:23 17.jpeg
-rw-rw-r-- 1 ishwarya ishwarya 4882 Dec 3 15:22 16.jpeg
-rw-rw-r-- 1 ishwarya ishwarya 6402 Dec 3 15:22 15.jpeg
-rw-rw-r-- 1 ishwarya ishwarya 3103 Dec 3 15:22 14.jpeg
-rw-rw-r-- 1 ishwarya ishwarya 8484 Dec 3 15:22 13.jpeg
-rw-rw-r-- 1 ishwarya ishwarya 6296 Dec 3 15:22 12.jpeg
-rw-rw-r-- 1 ishwarya ishwarya 8051 Dec 3 15:21 11.jpeg
-rw-rw-r-- 1 ishwarya ishwarya 8526 Dec 3 15:20 9.jpeg
-rw-rw-r-- 1 ishwarya ishwarya 10177 Dec 3 15:20 8.jpeg
-rw-rw-r-- 1 ishwarya ishwarya 12701 Dec 3 15:20 7.jpeg
-rw-rw-r-- 1 ishwarya ishwarya 7803 Dec 3 15:20 6.jpeg
-rw-rw-r-- 1 ishwarya ishwarya 7412 Nov 28 11:41 5.jpeg
-rw-rw-r-- 1 ishwarya ishwarya 10559 Nov 28 11:38 4.jpeg
-rw-rw-r-- 1 ishwarya ishwarya 7294 Nov 28 11:34 3.jpeg
-rw-rw-r-- 1 ishwarya ishwarya 12722 Nov 28 11:29 2.jpeg
-rw-rw-r-- 1 ishwarya ishwarya 6736 Nov 28 11:29 1.jpeg
Re: display images in qt from text file
What have you tried so far?
Re: display images in qt from text file
Are those images stored inside some folder? or do you have only text file that contains the set of images? if you have images stored inside some folder, you can read all the ".jpeg" files inside that specific folder one by one for every 10 seconds and display it in QLabel.
Re: display images in qt from text file
Quote:
Originally Posted by
jakr13
Are those images stored inside some folder? or do you have only text file that contains the set of images?
The "text file" is a directory listing.
This looks like the typical forum spammer, who opens several threads for exaclty the same topic, with no or slight modificatons to the content in order to bind as much volunteer effort as possible.
Since I got spammed via PM as well, I am considering this a fact.
Cheers,
_
Re: display images in qt from text file
thank you friends..nw i sorted by jpeg images..and dispalying only very first images..bt i could not knw how to display every images one after another for evry 10 seconds.local folder contains images ,config file folder contains temp.txt file Guide me plsss
my text file nd coding
text file: /home/ishwarya/displayimages/configfile/temp.txt
10.jpeg
27.jpeg
26.jpeg
25.jpeg
24.jpeg
23.jpeg
22.jpeg
21.jpeg
20.jpeg
19.jpeg
18.jpeg
17.jpeg
16.jpeg
15.jpeg
14.jpeg
13.jpeg
12.jpeg
11.jpeg
9.jpeg
8.jpeg
7.jpeg
6.jpeg
5.jpeg
4.jpeg
3.jpeg
2.jpeg
1.jpeg
my coding
Code:
#include "widget.h"
#include "ui_widget.h"
#include <QtGui>
ui(new Ui::Widget)
{
QString filePath1
("/home/ishwarya/displayimages/configfile");
// path for temp.txt file QString filePath2
("/home/ishwarya/displayimages/local");
// path for images QString sortedimagesfilenameslist
="temp.txt";
// it contains list of sorted images dir.cd(filePath1);
file.setFileName(dir.absoluteFilePath(sortedimagesfilenameslist));
imagefilename= stream.readLine();
qDebug()<<imagefilename;
dir.cd(filePath2);
qDebug()<<dir;
file1.setFileName(dir.absoluteFilePath(imagefilename));
qDebug()<<file1.exists();
QImage *img
= new QImage(dir.
absoluteFilePath(imagefilename
));
QPixmap map
= QPixmap::fromImage(img
->scaled
(900,
900,Qt
::KeepAspectRatio,Qt
::FastTransformation));
imageLabel->setPixmap(map);
imageLabel->showFullScreen();
imageLabel->show();
ui->setupUi(this);
}
Re: display images in qt from text file
Is this some kind of school project?
3 Attachment(s)
Re: display images in qt from text file
You can check the program attached, which I did few years back and I think you will get some ideas from it. I used C++ style to read the directory and I have a pushbutton in GUI to start displaying images in label. You can have QTimer in constructor instead of pushbutton.
Note: dirent.h will works on linux but i doubt on windows.
cheers!!!
Re: display images in qt from text file
thank you so much sir
Quote:
Originally Posted by
jakr13
You can check the program attached, which I did few years back and I think you will get some ideas from it. I used C++ style to read the directory and I have a pushbutton in GUI to start displaying images in label. You can have QTimer in constructor instead of pushbutton.
Note: dirent.h will works on linux but i doubt on windows.
cheers!!!
Added after 20 minutes:
hello Mr. wysota.
Am a fresher sir jus nw i joined Embedded with Qt .nw training was going on..sir
2 Attachment(s)
Re: display images in qt from text file
Hi iswarya,
check the updated piece of code attached to help you how the QTimer can be used in a constructor!!!
jakr13
Re: display images in qt from text file
thank you sir
bt in my concept i have two file one file was jpeg images another file was sorted images with name sir i have to combine this both
Quote:
Originally Posted by
jakr13
Hi iswarya,
check the updated piece of code attached to help you how the QTimer can be used in a constructor!!!
jakr13
Added after 4 minutes:
my task concept was:
i have a folder it contains lot of jpeg images..i have to sort this images and putd in textfile by linux.i have one more file it contains timer
it says local image=10 seconds,by reading this timer file i have to display the images for evry 10 seconds.so my codinf should link sorted text file ,timer text file,images file(jpeg).
i want to show slideshow.. (every 10 seconds images should automaticaly change)
this was my concept sir
sir pls kindly help me in my coding itself sir
using for loop i can able to display every images after 10 seconds,,i dnt knw how to put
so pls help me sir
my coding
Code:
#include "widget.h"
#include "ui_widget.h"
#include <QtGui>
ui(new Ui::Widget)
{
QString filePath1
("/home/ishwarya/displayimages/configfile");
// path for temp.txt file QString filePath2
("/home/ishwarya/displayimages/local");
// path for images QString sortedimagesfilenameslist
="temp.txt";
// it contains list of sorted images dir.cd(filePath1);
file.setFileName(dir.absoluteFilePath(sortedimages filenameslist));
imagefilename= stream.readLine();
qDebug()<<imagefilename;
dir.cd(filePath2);
qDebug()<<dir;
file1.setFileName(dir.absoluteFilePath(imagefilena me));
qDebug()<<file1.exists();
QImage *img
= new QImage(dir.
absoluteFilePath(imagefilename
));
QPixmap map
= QPixmap::fromImage(img
->scaled
(900,
900,Qt
::KeepAspectRatio,Qt
::FastTransf ormation
));
imageLabel->setPixmap(map);
imageLabel->showFullScreen();
imageLabel->show();
ui->setupUi(this);
}
Re: display images in qt from text file
Again, is this a school project of some sort?
Re: display images in qt from text file
i dnt knw abt its either school project or training project...bt this was my task sir..
Quote:
Originally Posted by
wysota
Again, is this a school project of some sort?
Re: display images in qt from text file
hello Mr jakr13
your code was so usefull to me.. thank you so much friend
Re: display images in qt from text file
got it working?
One more suggestion. You said you have three tasks. Its better that you make separate functions for every task and make function call.
Re: display images in qt from text file
k friend..bt i have one doubt..i completed local folder images for evry 10 seconds.i have one more folder [remote folder] it should display evry 5th minutes..my TL told read current time,, in that take seconds and make divide by 5 if its true display first images of remote folder for 10 seconds and go to remaing local folder images to display..
did yu knw how to calculate seconds from current time..plss help me frnd:(
Re: display images in qt from text file
Quote:
Originally Posted by
iswaryasenthilkumar
did yu knw how to calculate seconds from current time..plss help me frnd:(
Why don't you use a QTimer with an interval of 300 seconds (5*60) and connect the timer to the timeout signal to a slot in your app?
If you must calculate the seconds yourself for some reason, either QDateTime or QTime can be used to get the number of miliseconds and divide by 1,000 to get the number of seconds.
Re: display images in qt from text file
i calculated sir bt its not properly working for evry 5th minute..
my coding
Code:
if((time.second() %5 ) == 0)
{
ReadImagesfromRemoteFolder();
}
plss help me ...
Re: display images in qt from text file
You do understand that seconds and minutes are two different units of time, right?
Cheers,
_
Re: display images in qt from text file
thanks its working bt again one problem for evry 5th minute remote folder should display on image for 10 seconds next remaining local folder images should display..bt for me evry 5th minutes remote folder image dispalying next local images start from begining.. can any one help me plss.
Quote:
Originally Posted by
anda_skoa
You do understand that seconds and minutes are two different units of time, right?
Cheers,
_
Re: display images in qt from text file
Quote:
Originally Posted by
iswaryasenthilkumar
thanks its working bt again one problem for evry 5th minute remote folder should display on image for 10 seconds next remaining local folder images should display..bt for me evry 5th minutes remote folder image dispalying next local images start from begining.. can any one help me plss.
If I am not wrong, you should display image from remote folder for every 5th minute for 10 seconds and after that local images must be displayed. Am I right?
do you need the local images to be displayed every 10 seconds after that 5th minute 10 seconds?
if this is the case,you know now how to display images after 5th minute. After that, you can call the delay loop in my program which uses QTime::currenttime.addsecs(10) after calling the function "ReadFromRemoteFolder". It displays for 10 seconds after the 5th minute. Then read the images from the local folder for every 10sec.
jakr13