Transferring data streams over a network interface using libpcap and Qt is yet again complicating and introducing much frustration into my life.

The data to be transfered is stored in a QString in the following manner "0011223344" which is just a shorthand version of 0x00,0x11,0x22,0x33.. Data is maintained in this manner so it can be stored in a human readable text file and 0x omitted for space saving measures.

Now in order to send this data out over the network using
Qt Code:
  1. int pcap_sendpacket (pcap_t * p,u_char * buf, int size)
To copy to clipboard, switch view to plain text mode 
I must convert the QString into something u_char * compatible. A QByteArray appears to be the right container to accomplish this but I have encountered a few conversion problems.

From the docs there does not appear to be any shortcuts for converting a QString with data stored in this manner into a QByteArray. Coding a helper function to convert the data properly should be a trivial task, but the problem occurs with type casting and being able to have the pcap_send function accept the QByteArray as a u_char * argument.

I have tried multiple approaches in an attempt to solve this problem but all appear to be dead ends. We discussed this before in another thread but was unable to find a solution using its wisdom. Any enlightenment on the situation would be greatly appreciated.