Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QIODevice::bytesWritten ( qint64 bytes ) signal not working
Forum Updated to NodeBB v4.3 + New Features

QIODevice::bytesWritten ( qint64 bytes ) signal not working

Scheduled Pinned Locked Moved General and Desktop
13 Posts 5 Posters 8.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    koahnig
    wrote on last edited by
    #4

    As tobias Hunger has already suggested "bytesWritten":http://developer.qt.nokia.com/doc/qt-4.8/qiodevice.html#bytesWritten sais :
    [quote]This signal is emitted every time a payload of data has been written to the device. [/quote]
    you may use the "readyRead signal":http://developer.qt.nokia.com/doc/qt-4.8/qiodevice.html#readyRead and check the number of byte available with "bytesAvailable":http://developer.qt.nokia.com/doc/qt-4.8/qiodevice.html#bytesAvailable

    Vote the answer(s) that helped you to solve your issue(s)

    1 Reply Last reply
    0
    • S Offline
      S Offline
      shoyeb
      wrote on last edited by
      #5

      hey koahnig thanx for your reply,

      currently i am using readyRead() signal but now i want to replace it by bytesWritten() signal, but it seems to me that bytesWritten() signal is not working...

      can u please tell me wat could be the problem...

      There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #6

        Just a wild guess: you are not writing any data to the device, and hence, the bytesWritten signal is never emitted.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #7

          Why on earth do you want to replace it? That two signals serve two totally different purposes - of course it does not work! How come that you expect that this could work?

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • K Offline
            K Offline
            koahnig
            wrote on last edited by
            #8

            the problem is the direction of data.
            the readyRead signal will be emitted when data is available to read during input of data.
            the bytesWritten will be emitted when data has been written to device during output of data.

            Vote the answer(s) that helped you to solve your issue(s)

            1 Reply Last reply
            0
            • S Offline
              S Offline
              shoyeb
              wrote on last edited by
              #9

              for of all thanx to all for spending ur precious time with my problem.

              @ andre: the data is written into the device continously.

              @volker: i want to replace readyRead() signal because, readyRead() signal gives me random amount of data i.e whenever this signal is emitted it doesn't always give me same amount of data.

              So i wanted to replace it by bytesWritten() signal which will be emitted only when the specified amount of data is there in the IODevice.

              @koahnig: if the problem is about the direction of data, then i have no other option than to stick with the readRead() signal... :(

              thanx...

              There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code.

              1 Reply Last reply
              0
              • A Offline
                A Offline
                andre
                wrote on last edited by
                #10

                The data is written by whom? By your own application? In that case, you can use bytesWritten(). However, even in this case, the number of bytes written is out of your control. However, it seems that you're using readyRead() now, and that would mean that you are reading now.

                I'm really not sure what you want to achieve... Why is it an issue that you don't get a constant number of bytes from readyRead?

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  shoyeb
                  wrote on last edited by
                  #11

                  basically what i want is, every time when i get this signal ( bytesWritten() or readyRead() ) , i want constatnt number of bytes to be available to read...
                  but this is not happening when i used readyRead(), thats why i was trying to use bytesWritten() signal, but even after using bytesWritten() signal, if i am not able to control the number of bytes then i think i have to use readyRead only, i have no other option...

                  thanx andre...

                  There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code.

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    andre
                    wrote on last edited by
                    #12

                    No chance, with neither of the methods will give you such a guarantee. If you're reading, you cannot just use the bytesWritten signal because you think it suits your fancy. It just doesn't work that way.

                    For your actual issue, I would probably just:

                    ignore the signal if the number is lower than what I'd like, and

                    just read the wanted number of bytes if the number is equal or higher than what I'd like

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      shoyeb
                      wrote on last edited by
                      #13

                      thanx andre...

                      if that is the case then i will use readyRead() only...

                      thanx again for clearing my doubt....

                      There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code.

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved