Results 1 to 12 of 12

Thread: help me to slove

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2010
    Posts
    15
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    3

    Question help me to slove

    I am tring to shift enter chararter by 2 . That mean char "A" to "c".

    How it should work:
    1> I collect QString from LineEdit.
    2>Than get each ASCII value of SQtring
    3> Add 2 to ASCII Value
    4> Convert it to QString
    5> Show it to Thru LineEdit2

    Qt Code:
    1. QString pass3;
    2. QChar ch;
    3. int i,chValue;
    4.  
    5.  
    6. // Get Data
    7. QString str = ui->lineEdit->text();
    8.  
    9. // QString to char array;
    10. for(i=0; i<=str.size();i++)
    11. {
    12. // converted to number
    13. ch=str.at(i).toAscii();
    14. chValue = ch.toAscii();
    15.  
    16. chValue=chValue + 2;
    17.  
    18. // Number to Charecter and string in QSTRING
    19. pass3 += QChar(chVale);
    20.  
    21. }
    22.  
    23. ui->lineEdit_2->setText(pass3);
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: help me to slove

    So what is the problem exactly? If you make 'chVale' a char, it should work fine.

  3. #3
    Join Date
    Apr 2010
    Posts
    15
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    3

    Default Re: help me to slove

    These problem are showen on building:

    1>'QChar::QChar(char)' is private
    2>within this context
    3>'chVal' was not declared in this scope

  4. #4
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 334 Times in 317 Posts

    Default Re: help me to slove

    what happens if you change chValue a char, instead of int ? as wysota said ?
    Also the code and error doesnt match,, in error u say 'chaVal' but in code I dont see any such variable
    Also in pass3 += QChar(chVale); is chVale declared ?

  5. #5
    Join Date
    Apr 2010
    Posts
    15
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    3

    Default Re: help me to slove

    Ok, It was my typing mistake.

    I changed chVale to chValue and again compiled it and i got following error :


    1>'QChar::QChar(char)' is private
    2>within this context

    And please tell what does 1 and 2 means.

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

    Default Re: help me to slove

    It means you need to learn C++.

    Are you using Qt4 or Qt3? Qt4 (which is what your profile suggests you are using) surely has a public constructor taking a char so you shouldn't be getting that error.

  7. #7
    Join Date
    Apr 2010
    Posts
    15
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    3

    Default Re: help me to slove

    Quote Originally Posted by wysota View Post
    It means you need to learn C++.

    Are you using Qt4 or Qt3? Qt4 (which is what your profile suggests you are using) surely has a public constructor taking a char so you shouldn't be getting that error.

    Yes, I am new to C++ and I m using QT4 with sdk.

    Can u show how to do that.

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

    Default Re: help me to slove

    How to do what? Please provide the exact code you have now because right now we are chasing ghosts.

  9. #9
    Join Date
    Apr 2010
    Posts
    15
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    3

    Default Re: help me to slove

    This is what I want:
    ---------------------------------------------------
    1> I collect QString from LineEdit.

    2>Than get each ASCII value of SQtring

    3> Add 2 to ASCII Value

    4> Convert it to QString

    5> Show it to Thru LineEdit2


    // cpp
    Qt Code:
    1. void myapp01r::myappstr()
    2. {
    3.  
    4. QString pass3;
    5. QChar ch,ch2;
    6. int i,chValue;
    7.  
    8.  
    9. // Get Data
    10. QString str = ui->lineEdit->text();
    11.  
    12. // QString to char array;
    13. for(i=0; i<=str.size();i++)
    14. {
    15. // converted to number
    16. ch=str.at(i).toAscii();
    17. chValue = ch.toAscii();
    18.  
    19. chValue=chValue + 2;
    20.  
    21. // Number to Charecter and string in QSTRING
    22. pass3 += char(chValue);
    23.  
    24. }
    25.  
    26. ui->lineEdit_2->setText(pass3);
    27.  
    28. }
    To copy to clipboard, switch view to plain text mode 

    header
    Qt Code:
    1. private slots:
    2. void myappstr();
    To copy to clipboard, switch view to plain text mode 
    Last edited by askrina; 15th April 2010 at 11:03.

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

    Default Re: help me to slove

    And what is the error? With lines and everything, please.

    BTW. You are modifying the value of the character by 2 but then you are not using it anywhere.
    Last edited by wysota; 15th April 2010 at 10:48.

  11. #11
    Join Date
    Apr 2010
    Posts
    15
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    3

    Default Re: help me to slove

    I have changed it.
    AND I am getting following error
    1>'QChar::QChar(char)' is private
    2>within this context

Similar Threads

  1. Replies: 4
    Last Post: 30th June 2009, 11:12

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.