Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 2

Qt-interest Archive, April 2007
Image on QT form for some interval


Message 1 in thread

hi everybody,


I want to show jpeg images for some time interval(6 second).
i used

 fm->setPalatteBackgroundPixmap(QPixmap("aaa.jpeg")) (for showing image on
form.)
 QApplication::eventLoop()->processEvents(QEventLoop::AllEvents,100);
 sleep(6);
 printf("HIIIIIIIIIIII");

 fm->setPalatteBackgroundPixmap(QPixmap("bbb.jpeg")) (for showing image on
form.)
 QApplication::eventLoop()->processEvents(QEventLoop::AllEvents,100);
 sleep(6);
 printf("BYEEEEEEEEEEEE");





it works fine.

but some times after showing image on form, application blocks and doesn't
execute  printf("HIIIIIIIIIIII") and other statements;

Can anybody tell me why it is happening. only sleep(6) doesn't work.

Is there any other method to show image for some time interval.


I tried QTimer::singleshot also, but it also blocks the application for
some time.



Tnanks and Regards,
Niranjan.


--
 [ signature omitted ] 

Message 2 in thread

Hi,

> I want to show jpeg images for some time interval(6 second).
> [...]
>  sleep(6);

Don't call sleep() in an event-driven program. Always keep your 
functions short and return control to the event loop:
	http://www.google.com/search?q=event-driven+programming

So instead of calling sleep() which is a blocking function, give control 
back to the event loop and use a QTimer to have the event loop "call you 
back" after 6 seconds.

--
 [ signature omitted ] 

Message 3 in thread

hi,

But QTimer is nonblocking function.
Suppose i used,


fm->setPaletteBackgroundPixmap(QPixmap("aaaa.jpg"));
QTimer(6000,fm.slot(nextWindow()));
fm->setPaletteBackgroundPixmap(QPixmap("cccc.jpg"));

void Form1::nextWindow()
{
fm->setPaletteBackgroundPixmap(QPixmap("bbbb.jpg"));
}




I want, first image aaaa displayed, then wait for 6 sec. thn image bbbb
displayed and then image cccc displayed.
but because of QTimer is nonblocking function, first aaaa image comes,
then cccc image and then bbbb image after time out.


what is the solution, plz tell me.


Thanks and Regards,
Niranjan.


> Hi,
>
>> I want to show jpeg images for some time interval(6 second).
>> [...]
>>  sleep(6);
>
> Don't call sleep() in an event-driven program. Always keep your
> functions short and return control to the event loop:
> 	http://www.google.com/search?q=event-driven+programming
>
> So instead of calling sleep() which is a blocking function, give control
> back to the event loop and use a QTimer to have the event loop "call you
> back" after 6 seconds.
>
> --
> Dimitri
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>
>

--
 [ signature omitted ] 

Message 4 in thread

axistech - the developers of blocking gui's and the memory free tool

> hi,
> 
> But QTimer is nonblocking function.
> Suppose i used,
> 
> 
> fm->setPaletteBackgroundPixmap(QPixmap("aaaa.jpg"));
> QTimer(6000,fm.slot(nextWindow()));
> fm->setPaletteBackgroundPixmap(QPixmap("cccc.jpg"));
> 
> void Form1::nextWindow()
> {
> fm->setPaletteBackgroundPixmap(QPixmap("bbbb.jpg"));
> }
> 
> 
> 
> 
> I want, first image aaaa displayed, then wait for 6 sec. thn image bbbb
> displayed and then image cccc displayed.
> but because of QTimer is nonblocking function, first aaaa image comes,
> then cccc image and then bbbb image after time out.
> 
> 
> what is the solution, plz tell me.
> 
> 
> Thanks and Regards,
> Niranjan.
> 
> 
> 
>>Hi,
>>
>>
>>>I want to show jpeg images for some time interval(6 second).
>>>[...]
>>> sleep(6);
>>
>>Don't call sleep() in an event-driven program. Always keep your
>>functions short and return control to the event loop:
>>	http://www.google.com/search?q=event-driven+programming
>>
>>So instead of calling sleep() which is a blocking function, give control
>>back to the event loop and use a QTimer to have the event loop "call you
>>back" after 6 seconds.
>>
>>--
>>Dimitri
>>
>>--
>>To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
>>"unsubscribe" in the subject or the body.
>>List archive and information: http://lists.trolltech.com/qt-interest/
>>
>>
>>
> 
> 
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/

--
 [ signature omitted ] 

Message 5 in thread

Hello.. is there a quicker way to convert an integer to a QString value than 
the following code (that works, but seems to me a mess ;-) ):

int currentInteger=0 ;
[...]
currentInteger++;
ostringstream outStream;
outStream<<currentInteger;
std::string stdString;
stdString = outStream.str();
QString q_string (stdString.c_str());
emit upgradeLogArea(q_string);

Cheers,
    Antonello

--
 [ signature omitted ] 

Message 6 in thread

QString::setNum(int)
http://doc.trolltech.com/4.2/qstring.html#setNum

----- Original Message ----- 
From: "Antonello Lobianco" <blackhole@xxxxxxxxxxxx>
To: <qt-interest@xxxxxxxxxxxxx>
Sent: Saturday, April 14, 2007 6:19 PM
Subject: int 2 QString conversion...


> Hello.. is there a quicker way to convert an integer to a QString value 
> than
> the following code (that works, but seems to me a mess ;-) ):
>
> int currentInteger=0 ;
> [...]
> currentInteger++;
> ostringstream outStream;
> outStream<<currentInteger;
> std::string stdString;
> stdString = outStream.str();
> QString q_string (stdString.c_str());
> emit upgradeLogArea(q_string);
>
> Cheers,
>    Antonello
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with 
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
> 

--
 [ signature omitted ] 

Message 7 in thread

On 4/14/07, Antonello Lobianco <blackhole@xxxxxxxxxxxx> wrote:
> Hello.. is there a quicker way to convert an integer to a QString value than
> the following code (that works, but seems to me a mess ;-) ):
>
> int currentInteger=0 ;
> [...]
> currentInteger++;
> ostringstream outStream;
> outStream<<currentInteger;
> std::string stdString;
> stdString = outStream.str();
> QString q_string (stdString.c_str());
> emit upgradeLogArea(q_string);

QString q_string = QString::number(currentInteger);

--
 [ signature omitted ] 

Message 8 in thread

> -----Original Message-----
> From: Larry Martell [mailto:larry.martell@xxxxxxxxx]
> Sent: Saturday, April 14, 2007 10:39 AM
> To: qt-interest@xxxxxxxxxxxxx
> Subject: Re: int 2 QString conversion...
> 
> On 4/14/07, Antonello Lobianco <blackhole@xxxxxxxxxxxx> wrote:
> > Hello.. is there a quicker way to convert an integer to a QString
value
> than
> > the following code (that works, but seems to me a mess ;-) ):
> >
> > int currentInteger=0 ;
> > [...]
> > currentInteger++;
> > ostringstream outStream;
> > outStream<<currentInteger;
> > std::string stdString;
> > stdString = outStream.str();
> > QString q_string (stdString.c_str());
> > emit upgradeLogArea(q_string);
> 
> QString q_string = QString::number(currentInteger);
And just for a 3rd quicker way... :)
QString( "%1" ).arg( num )

--
 [ signature omitted ] 

Message 9 in thread

thanks to all.. I was sure there must have been a quicker way ;-)))

cheers..
    Antonello

On Saturday 14 April 2007 21:44, Scott Aron Bloom wrote:
> > -----Original Message-----
> > From: Larry Martell [mailto:larry.martell@xxxxxxxxx]
> > Sent: Saturday, April 14, 2007 10:39 AM
> > To: qt-interest@xxxxxxxxxxxxx
> > Subject: Re: int 2 QString conversion...
> >
> > On 4/14/07, Antonello Lobianco <blackhole@xxxxxxxxxxxx> wrote:
> > > Hello.. is there a quicker way to convert an integer to a QString
>
> value
>
> > than
> >
> > > the following code (that works, but seems to me a mess ;-) ):
> > >
> > > int currentInteger=0 ;
> > > [...]
> > > currentInteger++;
> > > ostringstream outStream;
> > > outStream<<currentInteger;
> > > std::string stdString;
> > > stdString = outStream.str();
> > > QString q_string (stdString.c_str());
> > > emit upgradeLogArea(q_string);
> >
> > QString q_string = QString::number(currentInteger);
>
> And just for a 3rd quicker way... :)
> QString( "%1" ).arg( num )
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body. List archive and information:
> http://lists.trolltech.com/qt-interest/

-- 
 [ signature omitted ] 

Message 10 in thread

niranjank@xxxxxxxxxxxx wrote:
> hi,
> 
> But QTimer is nonblocking function.
> Suppose i used,
> 
> 
> fm->setPaletteBackgroundPixmap(QPixmap("aaaa.jpg"));
> QTimer(6000,fm.slot(nextWindow()));
> fm->setPaletteBackgroundPixmap(QPixmap("cccc.jpg"));
This is not the way to present sequential images using QTimer. What you 
should do is create a slot that is called by the QTimer timeout signal. 
Then set the background pixmap in the slot function. You would have to 
keep track of which pixmap is currently being displayed so that you know 
what the new one should be.
> 
> void Form1::nextWindow()
> {
> fm->setPaletteBackgroundPixmap(QPixmap("bbbb.jpg"));
> }
> 
> 
> 
> 
> I want, first image aaaa displayed, then wait for 6 sec. thn image bbbb
> displayed and then image cccc displayed.
> but because of QTimer is nonblocking function, first aaaa image comes,
> then cccc image and then bbbb image after time out.
> 
> 
> what is the solution, plz tell me.
> 
> 
> Thanks and Regards,
> Niranjan.
> 
> 
>> Hi,
>>
>>> I want to show jpeg images for some time interval(6 second).
>>> [...]
>>>  sleep(6);
>> Don't call sleep() in an event-driven program. Always keep your
>> functions short and return control to the event loop:
>> 	http://www.google.com/search?q=event-driven+programming
>>
>> So instead of calling sleep() which is a blocking function, give control
>> back to the event loop and use a QTimer to have the event loop "call you
>> back" after 6 seconds.
>>
>> --
>> Dimitri
>>
>> --
>> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
>> "unsubscribe" in the subject or the body.
>> List archive and information: http://lists.trolltech.com/qt-interest/
>>
>>
>>
> 
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/

--
 [ signature omitted ] 

Message 11 in thread

Hi,

> But QTimer is nonblocking function.

Exactly. Don't use use blocking functions in event-driven programs. At 
least not in a thread which runs an event loop.

--
 [ signature omitted ] 

Message 12 in thread

On Saturday 07 April 2007 22:18, niranjank@xxxxxxxxxxxx wrote:
> hi everybody,
>
>
> I want to show jpeg images for some time interval(6 second).
Maybe you can use QTimeLine for this. See:
http://doc.trolltech.com/4.2/qtimeline.html

Brad

Attachment:

Attachment: pgpiR55lSpomK.pgp
Description: PGP signature