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

Qt-interest Archive, May 2007
Updating a hidden widget


Message 1 in thread

Hi,
 
I am displaying an image in QTextBrowser. This image is unique for each
contactID. To change image  onContactUpdate() is called.
onContactUpdate() can be called when the Widget containing QTextBrowser
is NOT having focus.
The problem is that change in pixmap does not get reflected untill i
make window active. As soon as i click on it the change in pixmap is
reflected()
 
void onContactUpdate(QString contactId,QPixmap pixmap)
{
    QTextBrowser txt;
    txt->setAutoFillBackground(true); //doesnot help
    txt->document()->addResource(QTextDocument::ImageResource,
QUrl(contactId), pixmap);
    txt->update(); //doesnot help
    txt->repaint(); //doesnot help
}
 
(Using Qt 4.1.2 on windows xp) 
 
Any ideas?? 
Thanks,
J
 
 

Message 2 in thread

Please provide a reproducible minimal test case... clearly the code you provide will not build...  The more you provide... the more likely you will get an answer
 
Scott

________________________________

From: Jaya Meghani [mailto:Jaya.Meghani@xxxxxxxxxx]
Sent: Fri 5/18/2007 2:15 PM
To: qt-interest@xxxxxxxxxxxxx
Subject: Updating a hidden widget


Hi,
 
I am displaying an image in QTextBrowser. This image is unique for each contactID. To change image  onContactUpdate() is called.
onContactUpdate() can be called when the Widget containing QTextBrowser is NOT having focus.
The problem is that change in pixmap does not get reflected untill i make window active. As soon as i click on it the change in pixmap is reflected()
 
void onContactUpdate(QString contactId,QPixmap pixmap)
{
    QTextBrowser txt;
    txt->setAutoFillBackground(true); //doesnot help
    txt->document()->addResource(QTextDocument::ImageResource, QUrl(contactId), pixmap);
    txt->update(); //doesnot help
    txt->repaint(); //doesnot help
}
 
(Using Qt 4.1.2 on windows xp) 
 
Any ideas?? 
Thanks,
J
 
 

--
 [ signature omitted ] 

Message 3 in thread

Sorry for not providing code.
Here it is.It refers to first.png and second.png, attaching them too.
Please  put them in executable directory.

I change the image in QTextBrowser while focus is on newW. After that
messagebox pops up, then focus goes back to newW: note that image has
not refreshed. But if you close newW or click on text browser
window(main_window), image refreshes.
I want that image should be refreshed even when main_window doesnot have
focus.

#include <QApplication>
#include <QMainWindow>
#include <QMessageBox>
#include <QTextBrowser>
#include <QTextDocument>
#include <QUrl>
#include <QPixmap>
#include <QWidget>
#include <QVariant>

int main(int argc, char *argv[])
{
	QApplication app(argc, argv);
	QMainWindow *main_window = new QMainWindow();


	QPixmap pixmap("first.png");
	QTextBrowser *ptr = new QTextBrowser(main_window);
	QVariant vPixmap = pixmap;
	ptr->document()->addResource(QTextDocument::ImageResource,
QUrl("1"), vPixmap);
	ptr->resize(500,500);
	main_window->resize(500,500);
	main_window->show();
	ptr->insertHtml("<img src=\"1\">");
	QWidget newW;
	newW.setGeometry(300,300,100,100);
	newW.show();
	QMessageBox::information(NULL,"Mesg","Change Now","ok");
	QPixmap pixmap_new("second.png");
	vPixmap = pixmap_new;
	//Overwrite the image resource with new pixmap.
	ptr->document()->addResource(QTextDocument::ImageResource,
QUrl("1"), vPixmap);
	ptr->repaint();

	return(app.exec());
}


Thanks,
j

> -----Original Message-----
> From: Scott Aron Bloom [mailto:scott@xxxxxxxxxxxx] 
> Sent: Friday, May 18, 2007 5:31 PM
> To: qt-interest@xxxxxxxxxxxxx
> Subject: RE: Updating a hidden widget
> 
> Please provide a reproducible minimal test case... clearly 
> the code you provide will not build...  The more you 
> provide... the more likely you will get an answer
>  
> Scott
> 
> ________________________________
> 
> From: Jaya Meghani [mailto:Jaya.Meghani@xxxxxxxxxx]
> Sent: Fri 5/18/2007 2:15 PM
> To: qt-interest@xxxxxxxxxxxxx
> Subject: Updating a hidden widget
> 
> 
> Hi,
>  
> I am displaying an image in QTextBrowser. This image is 
> unique for each contactID. To change image  onContactUpdate() 
> is called.
> onContactUpdate() can be called when the Widget containing 
> QTextBrowser is NOT having focus.
> The problem is that change in pixmap does not get reflected 
> untill i make window active. As soon as i click on it the 
> change in pixmap is reflected()
>  
> void onContactUpdate(QString contactId,QPixmap pixmap) {
>     QTextBrowser txt;
>     txt->setAutoFillBackground(true); //doesnot help
>     
> txt->document()->addResource(QTextDocument::ImageResource, 
> QUrl(contactId), pixmap);
>     txt->update(); //doesnot help
>     txt->repaint(); //doesnot help
> }
>  
> (Using Qt 4.1.2 on windows xp) 
>  
> Any ideas?? 
> Thanks,
> J
>  
>  
> 
> --
> 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/
> 

Attachment:

Attachment: second.png
Description: second.png

Attachment: first.png
Description: first.png


Message 4 in thread

Can anyone please help me on this. I posted it on weekend so might have
gone unnoticed :(
Problem - How to make sure a widget is repainted/reloaded when its
hidden. In this particular example it is Qtext Browser.
Here is small compilable code.

Qt4.1.2 on windows

I change the image in QTextBrowser while focus is on newW. After that
messagebox pops up, then focus goes back to newW: note that image has
not refreshed(in main_window). But if you close newW or click on text
browser window(main_window), image refreshes.
I want that image should be refreshed even when main_window doesnot have
focus.

#include <QApplication>
#include <QMainWindow>
#include <QMessageBox>
#include <QTextBrowser>
#include <QTextDocument>
#include <QUrl>
#include <QPixmap>
#include <QWidget>
#include <QVariant>

int main(int argc, char *argv[])
{
	QApplication app(argc, argv);
	QMainWindow *main_window = new QMainWindow();


	QPixmap pixmap("first.png");
	QTextBrowser *ptr = new QTextBrowser(main_window);
	QVariant vPixmap = pixmap;
	//Add first pixmap
	
ptr->document()->addResource(QTextDocument::ImageResource,QUrl("1"),
vPixmap);
	ptr->resize(500,500);
	main_window->resize(500,500);
	main_window->show();
	ptr->insertHtml("<img src=\"1\">");

	//To make sure main window does not have focus
	QWidget newW;
	newW.setGeometry(300,300,100,100);
	newW.show();

	QMessageBox::information(NULL,"Mesg","Change Now","ok");

	//Change pixmap
	QPixmap pixmap_new("second.png");
	vPixmap = pixmap_new;
	//Overwrite the image resource with new pixmap.
	ptr->document()->addResource(QTextDocument::ImageResource,
	QUrl("1"), vPixmap);
	//does not change the image
	ptr->repaint();

	return(app.exec());
}


Thanks,
J

> -----Original Message-----
> From: Jaya Meghani [mailto:Jaya.Meghani@xxxxxxxxxx] 
> Sent: Friday, May 18, 2007 5:59 PM
> To: Scott Aron Bloom; qt-interest@xxxxxxxxxxxxx
> Subject: RE: Updating a hidden widget
> 
> Sorry for not providing code.
> Here it is.It refers to first.png and second.png, attaching them too.
> Please  put them in executable directory.
> 
> I change the image in QTextBrowser while focus is on newW. 
> After that messagebox pops up, then focus goes back to newW: 
> note that image has not refreshed. But if you close newW or 
> click on text browser window(main_window), image refreshes.
> I want that image should be refreshed even when main_window 
> doesnot have focus.
> 
> #include <QApplication>
> #include <QMainWindow>
> #include <QMessageBox>
> #include <QTextBrowser>
> #include <QTextDocument>
> #include <QUrl>
> #include <QPixmap>
> #include <QWidget>
> #include <QVariant>
> 
> int main(int argc, char *argv[])
> {
> 	QApplication app(argc, argv);
> 	QMainWindow *main_window = new QMainWindow();
> 
> 
> 	QPixmap pixmap("first.png");
> 	QTextBrowser *ptr = new QTextBrowser(main_window);
> 	QVariant vPixmap = pixmap;
> 	ptr->document()->addResource(QTextDocument::ImageResource,
> QUrl("1"), vPixmap);
> 	ptr->resize(500,500);
> 	main_window->resize(500,500);
> 	main_window->show();
> 	ptr->insertHtml("<img src=\"1\">");
> 	QWidget newW;
> 	newW.setGeometry(300,300,100,100);
> 	newW.show();
> 	QMessageBox::information(NULL,"Mesg","Change Now","ok");
> 	QPixmap pixmap_new("second.png");
> 	vPixmap = pixmap_new;
> 	//Overwrite the image resource with new pixmap.
> 	ptr->document()->addResource(QTextDocument::ImageResource,
> QUrl("1"), vPixmap);
> 	ptr->repaint();
> 
> 	return(app.exec());
> }
> 
> 
> Thanks,
> j
> 
> > -----Original Message-----
> > From: Scott Aron Bloom [mailto:scott@xxxxxxxxxxxx]
> > Sent: Friday, May 18, 2007 5:31 PM
> > To: qt-interest@xxxxxxxxxxxxx
> > Subject: RE: Updating a hidden widget
> > 
> > Please provide a reproducible minimal test case... clearly the code 
> > you provide will not build...  The more you provide... the 
> more likely 
> > you will get an answer
> >  
> > Scott
> > 
> > ________________________________
> > 
> > From: Jaya Meghani [mailto:Jaya.Meghani@xxxxxxxxxx]
> > Sent: Fri 5/18/2007 2:15 PM
> > To: qt-interest@xxxxxxxxxxxxx
> > Subject: Updating a hidden widget
> > 
> > 
> > Hi,
> >  
> > I am displaying an image in QTextBrowser. This image is unique for 
> > each contactID. To change image  onContactUpdate() is called.
> > onContactUpdate() can be called when the Widget containing 
> > QTextBrowser is NOT having focus.
> > The problem is that change in pixmap does not get reflected 
> untill i 
> > make window active. As soon as i click on it the change in 
> pixmap is 
> > reflected()
> >  
> > void onContactUpdate(QString contactId,QPixmap pixmap) {
> >     QTextBrowser txt;
> >     txt->setAutoFillBackground(true); //doesnot help
> >     
> > txt->document()->addResource(QTextDocument::ImageResource,
> > QUrl(contactId), pixmap);
> >     txt->update(); //doesnot help
> >     txt->repaint(); //doesnot help
> > }
> >  
> > (Using Qt 4.1.2 on windows xp)
> >  
> > Any ideas?? 
> > Thanks,
> > J
> >  
> >  
> > 
> > --
> > 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

It was late Friday for me :)  Which meant, I forgot to send my response
then.  I actually did look at this.

It appears, that QT's text browser is not recognizing the changing of
the underlying resource as a requirement for repaint.

Im not sure if this is a bug or a feature... ;)  

The solution I found, was to reset the HTML as well, but that's probably
not ok for you, since I assume the 

	ptr->insertHtml("<img src=\"1\">");

call was an simplification for our sake.    

However, I definitely concur that the dirty flag is getting set, but the
update/paint call is not when only the resource is changed.  I would
sent it on to bugs at trolltech.com and hopefully they can fix it in
time for 4.3.

However, they may also have a solution... I could not get it to force a
repaint either.

Scott


> -----Original Message-----
> From: Jaya Meghani [mailto:Jaya.Meghani@xxxxxxxxxx]
> Sent: Tuesday, May 22, 2007 8:31 AM
> To: qt-interest@xxxxxxxxxxxxx
> Subject: RE: Updating a hidden widget
> 
> Can anyone please help me on this. I posted it on weekend so might
have
> gone unnoticed :(
> Problem - How to make sure a widget is repainted/reloaded when its
> hidden. In this particular example it is Qtext Browser.
> Here is small compilable code.
> 
> Qt4.1.2 on windows
> 
> I change the image in QTextBrowser while focus is on newW. After that
> messagebox pops up, then focus goes back to newW: note that image has
> not refreshed(in main_window). But if you close newW or click on text
> browser window(main_window), image refreshes.
> I want that image should be refreshed even when main_window doesnot
have
> focus.
> 
> #include <QApplication>
> #include <QMainWindow>
> #include <QMessageBox>
> #include <QTextBrowser>
> #include <QTextDocument>
> #include <QUrl>
> #include <QPixmap>
> #include <QWidget>
> #include <QVariant>
> 
> int main(int argc, char *argv[])
> {
> 	QApplication app(argc, argv);
> 	QMainWindow *main_window = new QMainWindow();
> 
> 
> 	QPixmap pixmap("first.png");
> 	QTextBrowser *ptr = new QTextBrowser(main_window);
> 	QVariant vPixmap = pixmap;
> 	//Add first pixmap
> 
> ptr->document()->addResource(QTextDocument::ImageResource,QUrl("1"),
> vPixmap);
> 	ptr->resize(500,500);
> 	main_window->resize(500,500);
> 	main_window->show();
> 	ptr->insertHtml("<img src=\"1\">");
> 
> 	//To make sure main window does not have focus
> 	QWidget newW;
> 	newW.setGeometry(300,300,100,100);
> 	newW.show();
> 
> 	QMessageBox::information(NULL,"Mesg","Change Now","ok");
> 
> 	//Change pixmap
> 	QPixmap pixmap_new("second.png");
> 	vPixmap = pixmap_new;
> 	//Overwrite the image resource with new pixmap.
> 	ptr->document()->addResource(QTextDocument::ImageResource,
> 	QUrl("1"), vPixmap);
> 	//does not change the image
> 	ptr->repaint();
> 
> 	return(app.exec());
> }
> 
> 
> Thanks,
> J
> 
> > -----Original Message-----
> > From: Jaya Meghani [mailto:Jaya.Meghani@xxxxxxxxxx]
> > Sent: Friday, May 18, 2007 5:59 PM
> > To: Scott Aron Bloom; qt-interest@xxxxxxxxxxxxx
> > Subject: RE: Updating a hidden widget
> >
> > Sorry for not providing code.
> > Here it is.It refers to first.png and second.png, attaching them
too.
> > Please  put them in executable directory.
> >
> > I change the image in QTextBrowser while focus is on newW.
> > After that messagebox pops up, then focus goes back to newW:
> > note that image has not refreshed. But if you close newW or
> > click on text browser window(main_window), image refreshes.
> > I want that image should be refreshed even when main_window
> > doesnot have focus.
> >
> > #include <QApplication>
> > #include <QMainWindow>
> > #include <QMessageBox>
> > #include <QTextBrowser>
> > #include <QTextDocument>
> > #include <QUrl>
> > #include <QPixmap>
> > #include <QWidget>
> > #include <QVariant>
> >
> > int main(int argc, char *argv[])
> > {
> > 	QApplication app(argc, argv);
> > 	QMainWindow *main_window = new QMainWindow();
> >
> >
> > 	QPixmap pixmap("first.png");
> > 	QTextBrowser *ptr = new QTextBrowser(main_window);
> > 	QVariant vPixmap = pixmap;
> > 	ptr->document()->addResource(QTextDocument::ImageResource,
> > QUrl("1"), vPixmap);
> > 	ptr->resize(500,500);
> > 	main_window->resize(500,500);
> > 	main_window->show();
> > 	ptr->insertHtml("<img src=\"1\">");
> > 	QWidget newW;
> > 	newW.setGeometry(300,300,100,100);
> > 	newW.show();
> > 	QMessageBox::information(NULL,"Mesg","Change Now","ok");
> > 	QPixmap pixmap_new("second.png");
> > 	vPixmap = pixmap_new;
> > 	//Overwrite the image resource with new pixmap.
> > 	ptr->document()->addResource(QTextDocument::ImageResource,
> > QUrl("1"), vPixmap);
> > 	ptr->repaint();
> >
> > 	return(app.exec());
> > }
> >
> >
> > Thanks,
> > j
> >
> > > -----Original Message-----
> > > From: Scott Aron Bloom [mailto:scott@xxxxxxxxxxxx]
> > > Sent: Friday, May 18, 2007 5:31 PM
> > > To: qt-interest@xxxxxxxxxxxxx
> > > Subject: RE: Updating a hidden widget
> > >
> > > Please provide a reproducible minimal test case... clearly the
code
> > > you provide will not build...  The more you provide... the
> > more likely
> > > you will get an answer
> > >
> > > Scott
> > >
> > > ________________________________
> > >
> > > From: Jaya Meghani [mailto:Jaya.Meghani@xxxxxxxxxx]
> > > Sent: Fri 5/18/2007 2:15 PM
> > > To: qt-interest@xxxxxxxxxxxxx
> > > Subject: Updating a hidden widget
> > >
> > >
> > > Hi,
> > >
> > > I am displaying an image in QTextBrowser. This image is unique for
> > > each contactID. To change image  onContactUpdate() is called.
> > > onContactUpdate() can be called when the Widget containing
> > > QTextBrowser is NOT having focus.
> > > The problem is that change in pixmap does not get reflected
> > untill i
> > > make window active. As soon as i click on it the change in
> > pixmap is
> > > reflected()
> > >
> > > void onContactUpdate(QString contactId,QPixmap pixmap) {
> > >     QTextBrowser txt;
> > >     txt->setAutoFillBackground(true); //doesnot help
> > >
> > > txt->document()->addResource(QTextDocument::ImageResource,
> > > QUrl(contactId), pixmap);
> > >     txt->update(); //doesnot help
> > >     txt->repaint(); //doesnot help
> > > }
> > >
> > > (Using Qt 4.1.2 on windows xp)
> > >
> > > Any ideas??
> > > Thanks,
> > > J
> > >
> > >
> > >
> > > --
> > > 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 6 in thread

Thanks for replying just wanted to make sure I am not missing something.

Reset the HTML as you guessed is not an option.
Will report same to trolltech.com .

Regards,
Jaya

> -----Original Message-----
> From: Scott Aron Bloom [mailto:scott@xxxxxxxxxxxx] 
> Sent: Tuesday, May 22, 2007 11:53 AM
> To: qt-interest@xxxxxxxxxxxxx
> Subject: RE: Updating a hidden widget
> 
> It was late Friday for me :)  Which meant, I forgot to send 
> my response then.  I actually did look at this.
> 
> It appears, that QT's text browser is not recognizing the 
> changing of the underlying resource as a requirement for repaint.
> 
> Im not sure if this is a bug or a feature... ;)  
> 
> The solution I found, was to reset the HTML as well, but 
> that's probably not ok for you, since I assume the 
> 
> 	ptr->insertHtml("<img src=\"1\">");
> 
> call was an simplification for our sake.    
> 
> However, I definitely concur that the dirty flag is getting 
> set, but the update/paint call is not when only the resource 
> is changed.  I would sent it on to bugs at trolltech.com and 
> hopefully they can fix it in time for 4.3.
> 
> However, they may also have a solution... I could not get it 
> to force a repaint either.
> 
> Scott
> 
> 
> > -----Original Message-----
> > From: Jaya Meghani [mailto:Jaya.Meghani@xxxxxxxxxx]
> > Sent: Tuesday, May 22, 2007 8:31 AM
> > To: qt-interest@xxxxxxxxxxxxx
> > Subject: RE: Updating a hidden widget
> > 
> > Can anyone please help me on this. I posted it on weekend so might
> have
> > gone unnoticed :(
> > Problem - How to make sure a widget is repainted/reloaded when its 
> > hidden. In this particular example it is Qtext Browser.
> > Here is small compilable code.
> > 
> > Qt4.1.2 on windows
> > 
> > I change the image in QTextBrowser while focus is on newW. 
> After that 
> > messagebox pops up, then focus goes back to newW: note that 
> image has 
> > not refreshed(in main_window). But if you close newW or 
> click on text 
> > browser window(main_window), image refreshes.
> > I want that image should be refreshed even when main_window doesnot
> have
> > focus.
> > 
> > #include <QApplication>
> > #include <QMainWindow>
> > #include <QMessageBox>
> > #include <QTextBrowser>
> > #include <QTextDocument>
> > #include <QUrl>
> > #include <QPixmap>
> > #include <QWidget>
> > #include <QVariant>
> > 
> > int main(int argc, char *argv[])
> > {
> > 	QApplication app(argc, argv);
> > 	QMainWindow *main_window = new QMainWindow();
> > 
> > 
> > 	QPixmap pixmap("first.png");
> > 	QTextBrowser *ptr = new QTextBrowser(main_window);
> > 	QVariant vPixmap = pixmap;
> > 	//Add first pixmap
> > 
> > ptr->document()->addResource(QTextDocument::ImageResource,QUrl("1"),
> > vPixmap);
> > 	ptr->resize(500,500);
> > 	main_window->resize(500,500);
> > 	main_window->show();
> > 	ptr->insertHtml("<img src=\"1\">");
> > 
> > 	//To make sure main window does not have focus
> > 	QWidget newW;
> > 	newW.setGeometry(300,300,100,100);
> > 	newW.show();
> > 
> > 	QMessageBox::information(NULL,"Mesg","Change Now","ok");
> > 
> > 	//Change pixmap
> > 	QPixmap pixmap_new("second.png");
> > 	vPixmap = pixmap_new;
> > 	//Overwrite the image resource with new pixmap.
> > 	ptr->document()->addResource(QTextDocument::ImageResource,
> > 	QUrl("1"), vPixmap);
> > 	//does not change the image
> > 	ptr->repaint();
> > 
> > 	return(app.exec());
> > }
> > 
> > 
> > Thanks,
> > J
> > 
> > > -----Original Message-----
> > > From: Jaya Meghani [mailto:Jaya.Meghani@xxxxxxxxxx]
> > > Sent: Friday, May 18, 2007 5:59 PM
> > > To: Scott Aron Bloom; qt-interest@xxxxxxxxxxxxx
> > > Subject: RE: Updating a hidden widget
> > >
> > > Sorry for not providing code.
> > > Here it is.It refers to first.png and second.png, attaching them
> too.
> > > Please  put them in executable directory.
> > >
> > > I change the image in QTextBrowser while focus is on newW.
> > > After that messagebox pops up, then focus goes back to newW:
> > > note that image has not refreshed. But if you close newW 
> or click on 
> > > text browser window(main_window), image refreshes.
> > > I want that image should be refreshed even when 
> main_window doesnot 
> > > have focus.
> > >
> > > #include <QApplication>
> > > #include <QMainWindow>
> > > #include <QMessageBox>
> > > #include <QTextBrowser>
> > > #include <QTextDocument>
> > > #include <QUrl>
> > > #include <QPixmap>
> > > #include <QWidget>
> > > #include <QVariant>
> > >
> > > int main(int argc, char *argv[])
> > > {
> > > 	QApplication app(argc, argv);
> > > 	QMainWindow *main_window = new QMainWindow();
> > >
> > >
> > > 	QPixmap pixmap("first.png");
> > > 	QTextBrowser *ptr = new QTextBrowser(main_window);
> > > 	QVariant vPixmap = pixmap;
> > > 	ptr->document()->addResource(QTextDocument::ImageResource,
> > > QUrl("1"), vPixmap);
> > > 	ptr->resize(500,500);
> > > 	main_window->resize(500,500);
> > > 	main_window->show();
> > > 	ptr->insertHtml("<img src=\"1\">");
> > > 	QWidget newW;
> > > 	newW.setGeometry(300,300,100,100);
> > > 	newW.show();
> > > 	QMessageBox::information(NULL,"Mesg","Change Now","ok");
> > > 	QPixmap pixmap_new("second.png");
> > > 	vPixmap = pixmap_new;
> > > 	//Overwrite the image resource with new pixmap.
> > > 	ptr->document()->addResource(QTextDocument::ImageResource,
> > > QUrl("1"), vPixmap);
> > > 	ptr->repaint();
> > >
> > > 	return(app.exec());
> > > }
> > >
> > >
> > > Thanks,
> > > j
> > >
> > > > -----Original Message-----
> > > > From: Scott Aron Bloom [mailto:scott@xxxxxxxxxxxx]
> > > > Sent: Friday, May 18, 2007 5:31 PM
> > > > To: qt-interest@xxxxxxxxxxxxx
> > > > Subject: RE: Updating a hidden widget
> > > >
> > > > Please provide a reproducible minimal test case... clearly the
> code
> > > > you provide will not build...  The more you provide... the
> > > more likely
> > > > you will get an answer
> > > >
> > > > Scott
> > > >
> > > > ________________________________
> > > >
> > > > From: Jaya Meghani [mailto:Jaya.Meghani@xxxxxxxxxx]
> > > > Sent: Fri 5/18/2007 2:15 PM
> > > > To: qt-interest@xxxxxxxxxxxxx
> > > > Subject: Updating a hidden widget
> > > >
> > > >
> > > > Hi,
> > > >
> > > > I am displaying an image in QTextBrowser. This image is 
> unique for 
> > > > each contactID. To change image  onContactUpdate() is called.
> > > > onContactUpdate() can be called when the Widget containing 
> > > > QTextBrowser is NOT having focus.
> > > > The problem is that change in pixmap does not get reflected
> > > untill i
> > > > make window active. As soon as i click on it the change in
> > > pixmap is
> > > > reflected()
> > > >
> > > > void onContactUpdate(QString contactId,QPixmap pixmap) {
> > > >     QTextBrowser txt;
> > > >     txt->setAutoFillBackground(true); //doesnot help
> > > >
> > > > txt->document()->addResource(QTextDocument::ImageResource,
> > > > QUrl(contactId), pixmap);
> > > >     txt->update(); //doesnot help
> > > >     txt->repaint(); //doesnot help }
> > > >
> > > > (Using Qt 4.1.2 on windows xp)
> > > >
> > > > Any ideas??
> > > > Thanks,
> > > > J
> > > >
> > > >
> > > >
> > > > --
> > > > 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/
> 
> --
> 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

It certainly could be a bug, so I would still recommend pointing it out
to Trolltech.  However, there are a couple of other options which might
work for you:

First, you can use the activateWindow() function to give focus to the
window, the same as a mouse click would.  As I think you mentioned,
clicking the window repaints the image.

The other thing that worked for me was to use the
setUpdatesEnabled(bool) function on either the window or the
QTextBrowser.  For example, the following code repaints the image on my
system without changing window focus:

    ptr->setUpdatesEnabled(false);
    //Change pixmap
    QPixmap pixmap_new("second.png");
    vPixmap = pixmap_new;
    //Overwrite the image resource with new pixmap.
    ptr->document()->addResource(QTextDocument::ImageResource,
    QUrl("1"), vPixmap);
    //does not change the image
    //ptr->repaint();
    ptr->setUpdatesEnabled(true);

I believe the reason this works is that setUpdatesEnabled(false)
disables the widget and the second call setUpdatesEnabled(true)
re-enables it, which immediately causes a repaint through the update()
function.

Hope that helps for your particular situation.

Stuart

> Thanks for replying just wanted to make sure I am not missing something.
>
> Reset the HTML as you guessed is not an option.
> Will report same to trolltech.com .
>
> Regards,
> Jaya
>
>   
>> -----Original Message-----
>> From: Scott Aron Bloom [mailto:scott@xxxxxxxxxxxx] 
>> Sent: Tuesday, May 22, 2007 11:53 AM
>> To: qt-interest@xxxxxxxxxxxxx
>> Subject: RE: Updating a hidden widget
>>
>> It was late Friday for me :)  Which meant, I forgot to send 
>> my response then.  I actually did look at this.
>>
>> It appears, that QT's text browser is not recognizing the 
>> changing of the underlying resource as a requirement for repaint.
>>
>> Im not sure if this is a bug or a feature... ;)  
>>
>> The solution I found, was to reset the HTML as well, but 
>> that's probably not ok for you, since I assume the 
>>
>> 	ptr->insertHtml("<img src=\"1\">");
>>
>> call was an simplification for our sake.    
>>
>> However, I definitely concur that the dirty flag is getting 
>> set, but the update/paint call is not when only the resource 
>> is changed.  I would sent it on to bugs at trolltech.com and 
>> hopefully they can fix it in time for 4.3.
>>
>> However, they may also have a solution... I could not get it 
>> to force a repaint either.
>>
>> Scott
>>
>>
>>     
>>> -----Original Message-----
>>> From: Jaya Meghani [mailto:Jaya.Meghani@xxxxxxxxxx]
>>> Sent: Tuesday, May 22, 2007 8:31 AM
>>> To: qt-interest@xxxxxxxxxxxxx
>>> Subject: RE: Updating a hidden widget
>>>
>>> Can anyone please help me on this. I posted it on weekend so might
>>>       
>> have
>>     
>>> gone unnoticed :(
>>> Problem - How to make sure a widget is repainted/reloaded when its 
>>> hidden. In this particular example it is Qtext Browser.
>>> Here is small compilable code.
>>>
>>> Qt4.1.2 on windows
>>>
>>> I change the image in QTextBrowser while focus is on newW. 
>>>       
>> After that 
>>     
>>> messagebox pops up, then focus goes back to newW: note that 
>>>       
>> image has 
>>     
>>> not refreshed(in main_window). But if you close newW or 
>>>       
>> click on text 
>>     
>>> browser window(main_window), image refreshes.
>>> I want that image should be refreshed even when main_window doesnot
>>>       
>> have
>>     
>>> focus.
>>>
>>> #include <QApplication>
>>> #include <QMainWindow>
>>> #include <QMessageBox>
>>> #include <QTextBrowser>
>>> #include <QTextDocument>
>>> #include <QUrl>
>>> #include <QPixmap>
>>> #include <QWidget>
>>> #include <QVariant>
>>>
>>> int main(int argc, char *argv[])
>>> {
>>> 	QApplication app(argc, argv);
>>> 	QMainWindow *main_window = new QMainWindow();
>>>
>>>
>>> 	QPixmap pixmap("first.png");
>>> 	QTextBrowser *ptr = new QTextBrowser(main_window);
>>> 	QVariant vPixmap = pixmap;
>>> 	//Add first pixmap
>>>
>>> ptr->document()->addResource(QTextDocument::ImageResource,QUrl("1"),
>>> vPixmap);
>>> 	ptr->resize(500,500);
>>> 	main_window->resize(500,500);
>>> 	main_window->show();
>>> 	ptr->insertHtml("<img src=\"1\">");
>>>
>>> 	//To make sure main window does not have focus
>>> 	QWidget newW;
>>> 	newW.setGeometry(300,300,100,100);
>>> 	newW.show();
>>>
>>> 	QMessageBox::information(NULL,"Mesg","Change Now","ok");
>>>
>>> 	//Change pixmap
>>> 	QPixmap pixmap_new("second.png");
>>> 	vPixmap = pixmap_new;
>>> 	//Overwrite the image resource with new pixmap.
>>> 	ptr->document()->addResource(QTextDocument::ImageResource,
>>> 	QUrl("1"), vPixmap);
>>> 	//does not change the image
>>> 	ptr->repaint();
>>>
>>> 	return(app.exec());
>>> }
>>>
>>>
>>> Thanks,
>>> J
>>>
>>>       
>>>> -----Original Message-----
>>>> From: Jaya Meghani [mailto:Jaya.Meghani@xxxxxxxxxx]
>>>> Sent: Friday, May 18, 2007 5:59 PM
>>>> To: Scott Aron Bloom; qt-interest@xxxxxxxxxxxxx
>>>> Subject: RE: Updating a hidden widget
>>>>
>>>> Sorry for not providing code.
>>>> Here it is.It refers to first.png and second.png, attaching them
>>>>         
>> too.
>>     
>>>> Please  put them in executable directory.
>>>>
>>>> I change the image in QTextBrowser while focus is on newW.
>>>> After that messagebox pops up, then focus goes back to newW:
>>>> note that image has not refreshed. But if you close newW 
>>>>         
>> or click on 
>>     
>>>> text browser window(main_window), image refreshes.
>>>> I want that image should be refreshed even when 
>>>>         
>> main_window doesnot 
>>     
>>>> have focus.
>>>>
>>>> #include <QApplication>
>>>> #include <QMainWindow>
>>>> #include <QMessageBox>
>>>> #include <QTextBrowser>
>>>> #include <QTextDocument>
>>>> #include <QUrl>
>>>> #include <QPixmap>
>>>> #include <QWidget>
>>>> #include <QVariant>
>>>>
>>>> int main(int argc, char *argv[])
>>>> {
>>>> 	QApplication app(argc, argv);
>>>> 	QMainWindow *main_window = new QMainWindow();
>>>>
>>>>
>>>> 	QPixmap pixmap("first.png");
>>>> 	QTextBrowser *ptr = new QTextBrowser(main_window);
>>>> 	QVariant vPixmap = pixmap;
>>>> 	ptr->document()->addResource(QTextDocument::ImageResource,
>>>> QUrl("1"), vPixmap);
>>>> 	ptr->resize(500,500);
>>>> 	main_window->resize(500,500);
>>>> 	main_window->show();
>>>> 	ptr->insertHtml("<img src=\"1\">");
>>>> 	QWidget newW;
>>>> 	newW.setGeometry(300,300,100,100);
>>>> 	newW.show();
>>>> 	QMessageBox::information(NULL,"Mesg","Change Now","ok");
>>>> 	QPixmap pixmap_new("second.png");
>>>> 	vPixmap = pixmap_new;
>>>> 	//Overwrite the image resource with new pixmap.
>>>> 	ptr->document()->addResource(QTextDocument::ImageResource,
>>>> QUrl("1"), vPixmap);
>>>> 	ptr->repaint();
>>>>
>>>> 	return(app.exec());
>>>> }
>>>>
>>>>
>>>> Thanks,
>>>> j
>>>>
>>>>         
>>>>> -----Original Message-----
>>>>> From: Scott Aron Bloom [mailto:scott@xxxxxxxxxxxx]
>>>>> Sent: Friday, May 18, 2007 5:31 PM
>>>>> To: qt-interest@xxxxxxxxxxxxx
>>>>> Subject: RE: Updating a hidden widget
>>>>>
>>>>> Please provide a reproducible minimal test case... clearly the
>>>>>           
>> code
>>     
>>>>> you provide will not build...  The more you provide... the
>>>>>           
>>>> more likely
>>>>         
>>>>> you will get an answer
>>>>>
>>>>> Scott
>>>>>
>>>>> ________________________________
>>>>>
>>>>> From: Jaya Meghani [mailto:Jaya.Meghani@xxxxxxxxxx]
>>>>> Sent: Fri 5/18/2007 2:15 PM
>>>>> To: qt-interest@xxxxxxxxxxxxx
>>>>> Subject: Updating a hidden widget
>>>>>
>>>>>
>>>>> Hi,
>>>>>
>>>>> I am displaying an image in QTextBrowser. This image is 
>>>>>           
>> unique for 
>>     
>>>>> each contactID. To change image  onContactUpdate() is called.
>>>>> onContactUpdate() can be called when the Widget containing 
>>>>> QTextBrowser is NOT having focus.
>>>>> The problem is that change in pixmap does not get reflected
>>>>>           
>>>> untill i
>>>>         
>>>>> make window active. As soon as i click on it the change in
>>>>>           
>>>> pixmap is
>>>>         
>>>>> reflected()
>>>>>
>>>>> void onContactUpdate(QString contactId,QPixmap pixmap) {
>>>>>     QTextBrowser txt;
>>>>>     txt->setAutoFillBackground(true); //doesnot help
>>>>>
>>>>> txt->document()->addResource(QTextDocument::ImageResource,
>>>>> QUrl(contactId), pixmap);
>>>>>     txt->update(); //doesnot help
>>>>>     txt->repaint(); //doesnot help }
>>>>>
>>>>> (Using Qt 4.1.2 on windows xp)
>>>>>
>>>>> Any ideas??
>>>>> Thanks,
>>>>> J
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> 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/
>>
>> --
>> 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/
>
>   


Attachment:

Attachment: signature.asc
Description: OpenPGP digital signature


Message 8 in thread

 
setUpdatesEnabled enabled like a charm. Thanks so much.

Regards,
J 
 

> -----Original Message-----
> From: Stuart Childs [mailto:childss@xxxxxxxxxxxxxxxx] 
> Sent: Tuesday, May 22, 2007 12:22 PM
> To: Jaya Meghani
> Cc: qt-interest@xxxxxxxxxxxxx
> Subject: Re: Updating a hidden widget
> 
> It certainly could be a bug, so I would still recommend 
> pointing it out to Trolltech.  However, there are a couple of 
> other options which might work for you:
> 
> First, you can use the activateWindow() function to give 
> focus to the window, the same as a mouse click would.  As I 
> think you mentioned, clicking the window repaints the image.
> 
> The other thing that worked for me was to use the
> setUpdatesEnabled(bool) function on either the window or the 
> QTextBrowser.  For example, the following code repaints the 
> image on my system without changing window focus:
> 
>     ptr->setUpdatesEnabled(false);
>     //Change pixmap
>     QPixmap pixmap_new("second.png");
>     vPixmap = pixmap_new;
>     //Overwrite the image resource with new pixmap.
>     ptr->document()->addResource(QTextDocument::ImageResource,
>     QUrl("1"), vPixmap);
>     //does not change the image
>     //ptr->repaint();
>     ptr->setUpdatesEnabled(true);
> 
> I believe the reason this works is that 
> setUpdatesEnabled(false) disables the widget and the second 
> call setUpdatesEnabled(true) re-enables it, which immediately 
> causes a repaint through the update() function.
> 
> Hope that helps for your particular situation.
> 
> Stuart
> 
> > Thanks for replying just wanted to make sure I am not 
> missing something.
> >
> > Reset the HTML as you guessed is not an option.
> > Will report same to trolltech.com .
> >
> > Regards,
> > Jaya
> >
> >   
> >> -----Original Message-----
> >> From: Scott Aron Bloom [mailto:scott@xxxxxxxxxxxx]
> >> Sent: Tuesday, May 22, 2007 11:53 AM
> >> To: qt-interest@xxxxxxxxxxxxx
> >> Subject: RE: Updating a hidden widget
> >>
> >> It was late Friday for me :)  Which meant, I forgot to send my 
> >> response then.  I actually did look at this.
> >>
> >> It appears, that QT's text browser is not recognizing the 
> changing of 
> >> the underlying resource as a requirement for repaint.
> >>
> >> Im not sure if this is a bug or a feature... ;)
> >>
> >> The solution I found, was to reset the HTML as well, but that's 
> >> probably not ok for you, since I assume the
> >>
> >> 	ptr->insertHtml("<img src=\"1\">");
> >>
> >> call was an simplification for our sake.    
> >>
> >> However, I definitely concur that the dirty flag is 
> getting set, but 
> >> the update/paint call is not when only the resource is changed.  I 
> >> would sent it on to bugs at trolltech.com and hopefully 
> they can fix 
> >> it in time for 4.3.
> >>
> >> However, they may also have a solution... I could not get 
> it to force 
> >> a repaint either.
> >>
> >> Scott
> >>
> >>
> >>     
> >>> -----Original Message-----
> >>> From: Jaya Meghani [mailto:Jaya.Meghani@xxxxxxxxxx]
> >>> Sent: Tuesday, May 22, 2007 8:31 AM
> >>> To: qt-interest@xxxxxxxxxxxxx
> >>> Subject: RE: Updating a hidden widget
> >>>
> >>> Can anyone please help me on this. I posted it on weekend so might
> >>>       
> >> have
> >>     
> >>> gone unnoticed :(
> >>> Problem - How to make sure a widget is repainted/reloaded 
> when its 
> >>> hidden. In this particular example it is Qtext Browser.
> >>> Here is small compilable code.
> >>>
> >>> Qt4.1.2 on windows
> >>>
> >>> I change the image in QTextBrowser while focus is on newW. 
> >>>       
> >> After that
> >>     
> >>> messagebox pops up, then focus goes back to newW: note that
> >>>       
> >> image has
> >>     
> >>> not refreshed(in main_window). But if you close newW or
> >>>       
> >> click on text
> >>     
> >>> browser window(main_window), image refreshes.
> >>> I want that image should be refreshed even when 
> main_window doesnot
> >>>       
> >> have
> >>     
> >>> focus.
> >>>
> >>> #include <QApplication>
> >>> #include <QMainWindow>
> >>> #include <QMessageBox>
> >>> #include <QTextBrowser>
> >>> #include <QTextDocument>
> >>> #include <QUrl>
> >>> #include <QPixmap>
> >>> #include <QWidget>
> >>> #include <QVariant>
> >>>
> >>> int main(int argc, char *argv[])
> >>> {
> >>> 	QApplication app(argc, argv);
> >>> 	QMainWindow *main_window = new QMainWindow();
> >>>
> >>>
> >>> 	QPixmap pixmap("first.png");
> >>> 	QTextBrowser *ptr = new QTextBrowser(main_window);
> >>> 	QVariant vPixmap = pixmap;
> >>> 	//Add first pixmap
> >>>
> >>> 
> ptr->document()->addResource(QTextDocument::ImageResource,QUrl("1"),
> >>> vPixmap);
> >>> 	ptr->resize(500,500);
> >>> 	main_window->resize(500,500);
> >>> 	main_window->show();
> >>> 	ptr->insertHtml("<img src=\"1\">");
> >>>
> >>> 	//To make sure main window does not have focus
> >>> 	QWidget newW;
> >>> 	newW.setGeometry(300,300,100,100);
> >>> 	newW.show();
> >>>
> >>> 	QMessageBox::information(NULL,"Mesg","Change Now","ok");
> >>>
> >>> 	//Change pixmap
> >>> 	QPixmap pixmap_new("second.png");
> >>> 	vPixmap = pixmap_new;
> >>> 	//Overwrite the image resource with new pixmap.
> >>> 	ptr->document()->addResource(QTextDocument::ImageResource,
> >>> 	QUrl("1"), vPixmap);
> >>> 	//does not change the image
> >>> 	ptr->repaint();
> >>>
> >>> 	return(app.exec());
> >>> }
> >>>
> >>>
> >>> Thanks,
> >>> J
> >>>
> >>>       
> >>>> -----Original Message-----
> >>>> From: Jaya Meghani [mailto:Jaya.Meghani@xxxxxxxxxx]
> >>>> Sent: Friday, May 18, 2007 5:59 PM
> >>>> To: Scott Aron Bloom; qt-interest@xxxxxxxxxxxxx
> >>>> Subject: RE: Updating a hidden widget
> >>>>
> >>>> Sorry for not providing code.
> >>>> Here it is.It refers to first.png and second.png, attaching them
> >>>>         
> >> too.
> >>     
> >>>> Please  put them in executable directory.
> >>>>
> >>>> I change the image in QTextBrowser while focus is on newW.
> >>>> After that messagebox pops up, then focus goes back to newW:
> >>>> note that image has not refreshed. But if you close newW
> >>>>         
> >> or click on
> >>     
> >>>> text browser window(main_window), image refreshes.
> >>>> I want that image should be refreshed even when
> >>>>         
> >> main_window doesnot
> >>     
> >>>> have focus.
> >>>>
> >>>> #include <QApplication>
> >>>> #include <QMainWindow>
> >>>> #include <QMessageBox>
> >>>> #include <QTextBrowser>
> >>>> #include <QTextDocument>
> >>>> #include <QUrl>
> >>>> #include <QPixmap>
> >>>> #include <QWidget>
> >>>> #include <QVariant>
> >>>>
> >>>> int main(int argc, char *argv[])
> >>>> {
> >>>> 	QApplication app(argc, argv);
> >>>> 	QMainWindow *main_window = new QMainWindow();
> >>>>
> >>>>
> >>>> 	QPixmap pixmap("first.png");
> >>>> 	QTextBrowser *ptr = new QTextBrowser(main_window);
> >>>> 	QVariant vPixmap = pixmap;
> >>>> 	ptr->document()->addResource(QTextDocument::ImageResource,
> >>>> QUrl("1"), vPixmap);
> >>>> 	ptr->resize(500,500);
> >>>> 	main_window->resize(500,500);
> >>>> 	main_window->show();
> >>>> 	ptr->insertHtml("<img src=\"1\">");
> >>>> 	QWidget newW;
> >>>> 	newW.setGeometry(300,300,100,100);
> >>>> 	newW.show();
> >>>> 	QMessageBox::information(NULL,"Mesg","Change Now","ok");
> >>>> 	QPixmap pixmap_new("second.png");
> >>>> 	vPixmap = pixmap_new;
> >>>> 	//Overwrite the image resource with new pixmap.
> >>>> 	ptr->document()->addResource(QTextDocument::ImageResource,
> >>>> QUrl("1"), vPixmap);
> >>>> 	ptr->repaint();
> >>>>
> >>>> 	return(app.exec());
> >>>> }
> >>>>
> >>>>
> >>>> Thanks,
> >>>> j
> >>>>
> >>>>         
> >>>>> -----Original Message-----
> >>>>> From: Scott Aron Bloom [mailto:scott@xxxxxxxxxxxx]
> >>>>> Sent: Friday, May 18, 2007 5:31 PM
> >>>>> To: qt-interest@xxxxxxxxxxxxx
> >>>>> Subject: RE: Updating a hidden widget
> >>>>>
> >>>>> Please provide a reproducible minimal test case... clearly the
> >>>>>           
> >> code
> >>     
> >>>>> you provide will not build...  The more you provide... the
> >>>>>           
> >>>> more likely
> >>>>         
> >>>>> you will get an answer
> >>>>>
> >>>>> Scott
> >>>>>
> >>>>> ________________________________
> >>>>>
> >>>>> From: Jaya Meghani [mailto:Jaya.Meghani@xxxxxxxxxx]
> >>>>> Sent: Fri 5/18/2007 2:15 PM
> >>>>> To: qt-interest@xxxxxxxxxxxxx
> >>>>> Subject: Updating a hidden widget
> >>>>>
> >>>>>
> >>>>> Hi,
> >>>>>
> >>>>> I am displaying an image in QTextBrowser. This image is
> >>>>>           
> >> unique for
> >>     
> >>>>> each contactID. To change image  onContactUpdate() is called.
> >>>>> onContactUpdate() can be called when the Widget containing 
> >>>>> QTextBrowser is NOT having focus.
> >>>>> The problem is that change in pixmap does not get reflected
> >>>>>           
> >>>> untill i
> >>>>         
> >>>>> make window active. As soon as i click on it the change in
> >>>>>           
> >>>> pixmap is
> >>>>         
> >>>>> reflected()
> >>>>>
> >>>>> void onContactUpdate(QString contactId,QPixmap pixmap) {
> >>>>>     QTextBrowser txt;
> >>>>>     txt->setAutoFillBackground(true); //doesnot help
> >>>>>
> >>>>> txt->document()->addResource(QTextDocument::ImageResource,
> >>>>> QUrl(contactId), pixmap);
> >>>>>     txt->update(); //doesnot help
> >>>>>     txt->repaint(); //doesnot help }
> >>>>>
> >>>>> (Using Qt 4.1.2 on windows xp)
> >>>>>
> >>>>> Any ideas??
> >>>>> Thanks,
> >>>>> J
> >>>>>
> >>>>>
> >>>>>
> >>>>> --
> >>>>> 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/
> >>
> >> --
> >> 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 9 in thread

Jaya Meghani wrote:
> Can anyone please help me on this. I posted it on weekend so might have
> gone unnoticed :(
> Problem - How to make sure a widget is repainted/reloaded when its
> hidden. In this particular example it is Qtext Browser.
> Here is small compilable code.
> Qt4.1.2 on windows
> 
> I change the image in QTextBrowser while focus is on newW. After that
> messagebox pops up, then focus goes back to newW: note that image has
> not refreshed(in main_window). But if you close newW or click on text
> browser window(main_window), image refreshes.
> I want that image should be refreshed even when main_window doesnot have
> focus.
Jaya,
	In your example you first setup the main window, then change it before 
calling app.exec(). The call to app.exec() starts the event loop, and 
changes to widgets will occur only after the event loop is running.
Also, don't call repaint(). Use update() instead.
To explore this issue with a small example, try creating a new class 
outside of main() that includes the code to change main_window. This 
will allow you make changes after the event loop is running.

> 
> #include <QApplication>
> #include <QMainWindow>
> #include <QMessageBox>
> #include <QTextBrowser>
> #include <QTextDocument>
> #include <QUrl>
> #include <QPixmap>
> #include <QWidget>
> #include <QVariant>
> 
> int main(int argc, char *argv[])
> {
> 	QApplication app(argc, argv);
> 	QMainWindow *main_window = new QMainWindow();
> 
> 
> 	QPixmap pixmap("first.png");
> 	QTextBrowser *ptr = new QTextBrowser(main_window);
> 	QVariant vPixmap = pixmap;
> 	//Add first pixmap
> 	
> ptr->document()->addResource(QTextDocument::ImageResource,QUrl("1"),
> vPixmap);
> 	ptr->resize(500,500);
> 	main_window->resize(500,500);
> 	main_window->show();
> 	ptr->insertHtml("<img src=\"1\">");
> 
> 	//To make sure main window does not have focus
> 	QWidget newW;
> 	newW.setGeometry(300,300,100,100);
> 	newW.show();
> 
> 	QMessageBox::information(NULL,"Mesg","Change Now","ok");
> 
> 	//Change pixmap
> 	QPixmap pixmap_new("second.png");
> 	vPixmap = pixmap_new;
> 	//Overwrite the image resource with new pixmap.
> 	ptr->document()->addResource(QTextDocument::ImageResource,
> 	QUrl("1"), vPixmap);
> 	//does not change the image
> 	ptr->repaint();
> 
> 	return(app.exec());
> }
> 
> 
> Thanks,
> J
> 
>> -----Original Message-----
>> From: Jaya Meghani [mailto:Jaya.Meghani@xxxxxxxxxx] 
>> Sent: Friday, May 18, 2007 5:59 PM
>> To: Scott Aron Bloom; qt-interest@xxxxxxxxxxxxx
>> Subject: RE: Updating a hidden widget
>>
>> Sorry for not providing code.
>> Here it is.It refers to first.png and second.png, attaching them too.
>> Please  put them in executable directory.
>>
>> I change the image in QTextBrowser while focus is on newW. 
>> After that messagebox pops up, then focus goes back to newW: 
>> note that image has not refreshed. But if you close newW or 
>> click on text browser window(main_window), image refreshes.
>> I want that image should be refreshed even when main_window 
>> doesnot have focus.
>>
>> #include <QApplication>
>> #include <QMainWindow>
>> #include <QMessageBox>
>> #include <QTextBrowser>
>> #include <QTextDocument>
>> #include <QUrl>
>> #include <QPixmap>
>> #include <QWidget>
>> #include <QVariant>
>>
>> int main(int argc, char *argv[])
>> {
>> 	QApplication app(argc, argv);
>> 	QMainWindow *main_window = new QMainWindow();
>>
>>
>> 	QPixmap pixmap("first.png");
>> 	QTextBrowser *ptr = new QTextBrowser(main_window);
>> 	QVariant vPixmap = pixmap;
>> 	ptr->document()->addResource(QTextDocument::ImageResource,
>> QUrl("1"), vPixmap);
>> 	ptr->resize(500,500);
>> 	main_window->resize(500,500);
>> 	main_window->show();
>> 	ptr->insertHtml("<img src=\"1\">");
>> 	QWidget newW;
>> 	newW.setGeometry(300,300,100,100);
>> 	newW.show();
>> 	QMessageBox::information(NULL,"Mesg","Change Now","ok");
>> 	QPixmap pixmap_new("second.png");
>> 	vPixmap = pixmap_new;
>> 	//Overwrite the image resource with new pixmap.
>> 	ptr->document()->addResource(QTextDocument::ImageResource,
>> QUrl("1"), vPixmap);
>> 	ptr->repaint();
>>
>> 	return(app.exec());
>> }
>>
>>
>> Thanks,
>> j
>>
>>> -----Original Message-----
>>> From: Scott Aron Bloom [mailto:scott@xxxxxxxxxxxx]
>>> Sent: Friday, May 18, 2007 5:31 PM
>>> To: qt-interest@xxxxxxxxxxxxx
>>> Subject: RE: Updating a hidden widget
>>>
>>> Please provide a reproducible minimal test case... clearly the code 
>>> you provide will not build...  The more you provide... the 
>> more likely 
>>> you will get an answer
>>>  
>>> Scott
>>>
>>> ________________________________
>>>
>>> From: Jaya Meghani [mailto:Jaya.Meghani@xxxxxxxxxx]
>>> Sent: Fri 5/18/2007 2:15 PM
>>> To: qt-interest@xxxxxxxxxxxxx
>>> Subject: Updating a hidden widget
>>>
>>>
>>> Hi,
>>>  
>>> I am displaying an image in QTextBrowser. This image is unique for 
>>> each contactID. To change image  onContactUpdate() is called.
>>> onContactUpdate() can be called when the Widget containing 
>>> QTextBrowser is NOT having focus.
>>> The problem is that change in pixmap does not get reflected 
>> untill i 
>>> make window active. As soon as i click on it the change in 
>> pixmap is 
>>> reflected()
>>>  
>>> void onContactUpdate(QString contactId,QPixmap pixmap) {
>>>     QTextBrowser txt;
>>>     txt->setAutoFillBackground(true); //doesnot help
>>>     
>>> txt->document()->addResource(QTextDocument::ImageResource,
>>> QUrl(contactId), pixmap);
>>>     txt->update(); //doesnot help
>>>     txt->repaint(); //doesnot help
>>> }
>>>  
>>> (Using Qt 4.1.2 on windows xp)
>>>  
>>> Any ideas?? 
>>> Thanks,
>>> J
>>>  
>>>  
>>>
>>> --
>>> 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 10 in thread

> I change the image in QTextBrowser while focus is on newW. After that
> messagebox pops up, then focus goes back to newW: note that image has
> not refreshed(in main_window). But if you close newW or click on text
> browser window(main_window), image refreshes.
> I want that image should be refreshed even when main_window doesnot have
> focus.
Jaya,
        In your example you first setup the main window, then change it before
calling app.exec(). The call to app.exec() starts the event loop, and
changes to widgets will occur only after the event loop is running.
Also, don't call repaint(). Use update() instead.
To explore this issue with a small example, try creating a new class
outside of main() that includes the code to change main_window. This
will allow you make changes after the event loop is running.

>
I actually tried exactly that...  I created  a custom QMainWindow, which created the sub windows and the messagebox.
There was no difference.
 
As someone else mentioned, calling activateWindow does work, but you see the titlebar flash etc. since you probably DONT want to actually give it activation, so I had to store the previous active window etc etc.
 
Also, setUpdateEnabled trik worked as well
 
Scott
 
 

--
 [ signature omitted ] 

Message 11 in thread

Hi,
 
I am displaying an image in QTextBrowser. This image is unique for each
contactID. To change image  onContactUpdate() is called.
onContactUpdate() can be called when the Widget containing QTextBrowser
is NOT having focus.
The problem is that change in pixmap does not get reflected untill i
make window active. As soon as i click on it the change in pixmap is
reflected()
 
void onContactUpdate(QString contactId,QPixmap pixmap)
{
    QTextBrowser txt;
    txt->setAutoFillBackground(true); //doesnot help
    txt->document()->addResource(QTextDocument::ImageResource,
QUrl(contactId), pixmap);
    txt->update(); //doesnot help
    txt->repaint(); //doesnot help
}
 
 
 
Any ideas?? 
Thanks,
J