Re: display images in qt from text file
Quote:
Originally Posted by
iswaryasenthilkumar
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:
Code:
if ((time.second() % 300) == 0)
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.
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
Code:
void Widget::ReadImagesfromlocalFolder()
{
QString filePath1
("/home/ishwarya/displayimages/configfile");
QString filePath2
("/home/ishwarya/displayimages/local");
QString sortedimagesfilenameslist
="temp.txt";
dir.cd(filePath1);
file.setFileName(dir.absoluteFilePath(sortedimagesfilenameslist));
for(int i=0;i<31;i++)
{
showFullScreen();
activateWindow();
imagefilename[i]= stream.readLine();
qDebug()<<"local:"<<imagefilename[i];
dir.cd(filePath2);
file1.setFileName(dir.absoluteFilePath(imagefilename[i]));
ImageToLoad.load(dir.absoluteFilePath(imagefilename[i]));
label
->setPixmap
(QPixmap::fromImage(ImageToLoad.
scaled(900,
900,Qt
::KeepAspectRatio,Qt
::FastTransformation)));
label->showFullScreen();
delay();
}
}
void Widget::ReadImagesfromRemoteFolder()
{
int j=0;
QString filePath1
("/home/ishwarya/displayimages/configfile");
QString filePath2
("/home/ishwarya/displayimages/remote");
QString sortedimagesfilenameslist
="tempp.txt";
dir.cd(filePath1);
file.setFileName(dir.absoluteFilePath(sortedimagesfilenameslist));
for(j=0;j<24;j++)
{
showFullScreen();
activateWindow();
imagefilename[j]= stream.readLine();
qDebug()<<"remote:"<<imagefilename[j];
dir.cd(filePath2);
file1.setFileName(dir.absoluteFilePath(imagefilename[j]));
ImageToLoad.load(dir.absoluteFilePath(imagefilename[j]));
label
->setPixmap
(QPixmap::fromImage(ImageToLoad.
scaled(900,
900,Qt
::KeepAspectRatio,Qt
::FastTransformation)));
label->showFullScreen();
delay();
ReadImagesfromlocalFolder();
}
}
void Widget::delay()
{
if((time.second() % 300 ) == 0)
{
ReadImagesfromRemoteFolder();
}
if(checklocalseconds=="local=10seconds")
{
sleepTime
= QTime::currentTime().
addSecs(10);
while(QTime::currentTime() < sleepTime
);
qDebug()<<"check";
}
}
Quote:
Originally Posted by
jthomps
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:
Code:
if ((time.seconds() % 300) == 0)
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.
Re: display images in qt from text file
Quote:
Originally Posted by
iswaryasenthilkumar
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:
- Use QTime and QTime::start() during your program's initialization.
- Use a QTimer with a 10 second interval and connect the QTimer timeout() signal to a slot in your program.
- In the slot above you can use QTime::elapsed() on the QTime variable you started in step 1.
- Divide the elapsed milliseconds by 1,000 to get the number of seconds.
- If seconds >= 300, display your remote image and use QTime::restart() to restart the QTime again.
- 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... :)
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..
Re: display images in qt from text file
Quote:
Originally Posted by
iswaryasenthilkumar
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.
Re: display images in qt from text file
K sir..I will try to improve my knowledge in Algorithm