Results 1 to 4 of 4

Thread: writing the variable value on port.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2007
    Posts
    83
    Thanks
    6
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Question writing the variable value on port.

    hi to all,
    regarding my project,i used qextserialport to communicate my gui with serialport.upto now i did evrything fine,but now i got one problem,i have to write the varible value on the port,while am using port->write("i");// 'i' is variable function instead of giving 'i' value simply am getting 'i'(charactor) on my hyperterminal.how can i avoid this.
    please provide some help with sample code or atleast function prototype.
    thanx in advance.

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

    Default Re: writing the variable value on port.

    You certainly shouldn't surround the variable name with quotes... And depending on the type of "i", you might need to convert it to a string.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: writing the variable value on port.

    You are writing "i" string to the port, not the variable. If you want to write variable's value, you have to first convert it to a byte array.

    You need something like:
    Qt Code:
    1. port->write( QString::number( i ).toAscii() );
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Sep 2007
    Posts
    83
    Thanks
    6
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: writing the variable value on port.

    thanx for ur sharp response.i did well with ur suggession.thank u.bye

Similar Threads

  1. Replies: 6
    Last Post: 18th April 2007, 15:04

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
  •  
Qt is a trademark of The Qt Company.