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

Qt-interest Archive, April 2007
Persistence of ActiveQt control


Message 1 in thread

Hi, ActiveQt users,

I turn ImageViewer(“C:\Qt\4.1.1\examples\widgets\imageviewer”) into an 
ActiveQt control.
Then, I start PowerPoint and insert the control, and in “Slide Show” use 
the control to load an image. It works fine.

After I saw the image I saved the PowerPoint file. I wish next time when 
I open the ppt file I can see the image directly --- that is what 
“Persistence” means.

What I did with the persistence of an ActiveQt control is by Q_PROPERTY 
and set STORED true.

class ImageViewer : public QMainWindow, public QAxBindable
{
Q_OBJECT
Q_PROPERTY( const QByteArray &data READ data WRITE setData STORED true)

public:
ImageViewer();

QByteArray data()const{return m_data;};
bool setData(const QByteArray &data);
. . .

QByteArray m_data;
};

My open file will read the whole image
QByteArray data = file.readAll();
and call setData():
bool ImageViewer::setData(const QByteArray &data)
{
m_data = data;
QImage image = QImage::fromData (data);

imageLabel->setPixmap(QPixmap::fromImage(image)); // for display

propertyChanged( "data" ); // acknowledge
return true;
}

The result is I do not see the image shows up in the ActiveX control. 
What's wrong?
Does anyone know the persistence of an activeQt control, or
Storage of Control Persistent Data in Qt?
http://msdn2.microsoft.com/en-us/library/aa768185.aspx

Thanks,
Lingfa


--
 [ signature omitted ]