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

Qt-interest Archive, March 2002
request to modify QSocket


Message 1 in thread

Hi,

I have a request not to close the socket, when QSocket is destructed.
For example using a method like:

QSocket::closeOnDestruct(bool);

QSocket::~QSocket()
{
#if defined(QSOCKET_DEBUG)
    qDebug( "QSocket (%s): Destroy", name() );
#endif
    if ( state() != Idle )
        close();
    ASSERT( d != 0 );
    delete d;
}

My problem is:
I have an ordinary socket but want to read an image using QIODevice. It works 
in principle, but the socket is closed by ~QSocket();

          // here I use my socket s

          // now I want to read an image
          QSocket qsocket;
          qsocket.setSocket(s);
          QImageIO qimageio;
          qimageio.setIODevice(&qsocket);
          qimageio.setFormat("BMP"); // BMP for example
          if( qimageio.read() )
          {
             ...
          }

          // here I still want to use my socket

Yours:
Rainer Lehrig