Results 1 to 3 of 3

Thread: converting of string to enum

Threaded 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

    Default converting of string to enum

    Hi
    I am using QextSerialPort class.with my application i am going to configure the port settings of my pc.
    to achieve the above tasks i collect the port setting parameters from my gui combo boxes(which are string type) and i converted "string" parameters to "enum" type using below expression

    Qt Code:
    1. QString portdbs=ui.comboBox_3->currentText();
    2. portdbs=portdbs.prepend("DATA_");
    3. DataBitsType dbs=(DataBitsType)Enum.Parse(typeof(DataBitsType), portdbs,true);
    4. port->setDataBits(dbs);
    To copy to clipboard, switch view to plain text mode 
    after this i compiled my application,but am getting below error:

    main.cpp:2381: error: `Enum' undeclared (first use this function)
    main.cpp:2381: error: (Each undeclared identifier is reported only once for each
    function it appears in.)
    main.cpp:2381: error: expected primary-expression before ')' token
    main.cpp:2381: error: expected `,' or `;' before "Enum"
    For avoiding that error i added "using System;" to my application,but surprisingly my edit plus editor is not detecting the "using"keyword(i.e the color is not changing)

    please help me on this issue.

    Thanks alot to all,
    Last edited by jpn; 24th October 2008 at 16:31. Reason: missing [code] tags

Similar Threads

  1. saving a c string of variable length in a shared memory?
    By nass in forum General Programming
    Replies: 4
    Last Post: 3rd January 2007, 14:40
  2. Converting number to string.
    By safknw in forum Newbie
    Replies: 2
    Last Post: 18th September 2006, 12:12
  3. enum property
    By illuzioner in forum Qt Tools
    Replies: 10
    Last Post: 22nd August 2006, 21:47
  4. converting string to unsigned integer
    By mgurbuz in forum Qt Programming
    Replies: 4
    Last Post: 12th May 2006, 09:46

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.