Results 1 to 10 of 10

Thread: Chaining QIODevice Instances

  1. #1
    Join Date
    Jan 2009
    Location
    Camp Lejeune, NC
    Posts
    24
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Chaining QIODevice Instances

    Is it customary in Qt4 to chain QIODevice-derived instances together?

    In .NET, we can chain streams together so that operating on one affects the rest.

    CryptoStream >> GZipStream >> NetworkStream

    Calling Write() on the CryptoStream would push the data through the GZipStream and then on through to the NetworkStream. Such is the way of doing things in the .NET world.

    Is this customary in Qt4 with QIODevice-based classes?
    Last edited by wswartzendruber; 29th July 2009 at 10:27.
    Lenovo ThinkPad T400 - Gentoo Linux 2008.0 Hardened
    Apple iBook G3 - Gentoo Linux 2008.0 Desktop
    Linksys WRT54GL - OpenWrt Kamikaze
    Linksys WRT310N - Stock Crap

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Chaining QIODevice Instances

    Qt only implements a single layer of devices. In other words, chaining existing QIODevice classes wouldn't make any sense. But it is possible (and actually used) to provide chaining mechanism for your own custom QIODevice. I once implemented an RC4 QIODevice that could be chained with any other QIODevice.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jan 2009
    Location
    Camp Lejeune, NC
    Posts
    24
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Chaining QIODevice Instances

    Quote Originally Posted by wysota View Post
    Qt only implements a single layer of devices. In other words, chaining existing QIODevice classes wouldn't make any sense. But it is possible (and actually used) to provide chaining mechanism for your own custom QIODevice. I once implemented an RC4 QIODevice that could be chained with any other QIODevice.
    I'm asking because I wrote a randomized encryption wrapper using .NET. The main class inherits the .NET Stream class. One of the constructor parameters is the stream you want to read plaintext from or write ciphertext to. Is this kosher with Qt4? I don't know exactly what type of chaining you did with your class.
    Lenovo ThinkPad T400 - Gentoo Linux 2008.0 Hardened
    Apple iBook G3 - Gentoo Linux 2008.0 Desktop
    Linksys WRT54GL - OpenWrt Kamikaze
    Linksys WRT310N - Stock Crap

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Chaining QIODevice Instances

    I'm sure the interfaces between Qt4 and .NET are not compatible. The concept of "stream" or "device" might be different (In Qt the device doesn't have to be a stream).

    My class worked similar to what you describe. The device was set using a dedicated method instead of the constructor, though.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Jan 2009
    Location
    Camp Lejeune, NC
    Posts
    24
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Chaining QIODevice Instances

    Here's a question: Why does QProcess provide both setStandardOutputFile and setStandardOutputProcess instead of just setStandardOutputIODevice? That way we could set a process to send its standard output to a QBuffer, a QTcpSocket, or anything that inherits QIODevice. QProcess itself inherits QIODevice.
    Lenovo ThinkPad T400 - Gentoo Linux 2008.0 Hardened
    Apple iBook G3 - Gentoo Linux 2008.0 Desktop
    Linksys WRT54GL - OpenWrt Kamikaze
    Linksys WRT310N - Stock Crap

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Chaining QIODevice Instances

    Because this functionality would have been probably used once per millenium. But feel free to suggest an improvement to QtSoftware, implementing it would probably take just a few minutes.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Jan 2009
    Location
    Camp Lejeune, NC
    Posts
    24
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Chaining QIODevice Instances

    Quote Originally Posted by wysota View Post
    Because this functionality would have been probably used once per millenium. But feel free to suggest an improvement to QtSoftware, implementing it would probably take just a few minutes.
    I put that bug report in to Qt Software. I justified the suggestion by saying we could pipe stdout from one QProcess through a pair of QTcpSockets and then to stdin of a QProcess on a completely different machine.

    Lenovo ThinkPad T400 - Gentoo Linux 2008.0 Hardened
    Apple iBook G3 - Gentoo Linux 2008.0 Desktop
    Linksys WRT54GL - OpenWrt Kamikaze
    Linksys WRT310N - Stock Crap

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Chaining QIODevice Instances

    You can do that even now with additional 4 lines of code (QProcess is a QIODevice itself). So the question remains - is it worth the effort.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    Jan 2009
    Location
    Camp Lejeune, NC
    Posts
    24
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Chaining QIODevice Instances

    Quote Originally Posted by wysota View Post
    You can do that even now with additional 4 lines of code (QProcess is a QIODevice itself). So the question remains - is it worth the effort.
    Can I get that code?
    Lenovo ThinkPad T400 - Gentoo Linux 2008.0 Hardened
    Apple iBook G3 - Gentoo Linux 2008.0 Desktop
    Linksys WRT54GL - OpenWrt Kamikaze
    Linksys WRT310N - Stock Crap

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Chaining QIODevice Instances

    Quote Originally Posted by wswartzendruber View Post
    Can I get that code?
    Two connect statements on either side of the network link plus two one line slots triggered upon readyRead() signals reading the available content from one device and pushing it to the other (process->socket and socket->process).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. The following user says thank you to wysota for this useful post:

    QPlace (30th July 2009)

Similar Threads

  1. Replies: 1
    Last Post: 25th July 2008, 17:54
  2. Video Stream, extending QIODevice
    By rextr in forum Qt Programming
    Replies: 3
    Last Post: 27th June 2008, 08:55

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.