Results 1 to 3 of 3

Thread: Getting const char * from QLineEdit

  1. #1
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Getting const char * from QLineEdit

    Is there an easy way of doing this? It seems that ui->TextEdit->text().toAscii().constData() returns garbage and on further investigation it seems to return a class that is freed before the method returns, so I have to assign it to a QByteArray first - QByteArray text = ui->TextEdit->text().toAscii()) and then use constData on that, which seems overly complicated for such a simple operation.

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Getting const char * from QLineEdit

    No one else has a solution for this? Copying to a QByteArray every time this is needed seems a little daft when other gui kits has simple things like c_str()

  3. #3
    Join Date
    May 2008
    Location
    Kyiv, Ukraine
    Posts
    418
    Thanks
    1
    Thanked 29 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Getting const char * from QLineEdit

    1. Why do you need const char*?
    2. yourLineEdit->text().toStdString().c_str();
    I'm a rebel in the S.D.G.

Similar Threads

  1. Qy 4.4.3 MySQL driver failed
    By pamalite in forum Installation and Deployment
    Replies: 2
    Last Post: 23rd January 2010, 01:09
  2. File rename detection
    By bunjee in forum Qt Programming
    Replies: 6
    Last Post: 23rd July 2009, 15:22
  3. shared vs static
    By alisami in forum Installation and Deployment
    Replies: 3
    Last Post: 4th October 2008, 13:04
  4. qt 4.2.2 install in tru64 cxx
    By try to remember in forum Installation and Deployment
    Replies: 0
    Last Post: 30th March 2007, 07:43
  5. QTableView paints too much
    By Jimmy2775 in forum Qt Programming
    Replies: 2
    Last Post: 26th July 2006, 18:42

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.