×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    13

    Problem with QString and QTextStream class

    I'm calling a very simple method for running Youtube video, but works only if I set for instance :
    out << "rtsp://v1.cache6.c.youtube.com/CjYLENy73wIaLQl7wJwlEuu8vRMYESARFEIJbXYtZ29vZ2xlSARSBXdhdGNoYJCCmb7WpIzYTQw=/0/0/0/video.3gp";

    But if I call this method with QString - (out << video << endl;), is not working and video.ram file is empty!

    Please someone to explain.

    bool WebHtmlWidget::runvideo(const QString &video)
    {

    QFile file("E://video.ram");
    file.open(QIODevice::WriteOnly | QIODevice::Text);
    QTextStream out(&file);

    out << video << endl;
    //out << "rtsp://v1.cache6.c.youtube.com/CjYLENy73wIaLQl7wJwlEuu8vRMYESARFEIJbXYtZ29vZ2xlSARSBXdhdGNoYJCCmb7WpIzYTQw=/0/0/0/video.3gp";
    file.close();

    QDesktopServices::openUrl(QUrl::fromLocalFile("E:/video.ram"));

    }

  2. #2
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: Problem with QString and QTextStream class

    "<<" expects a char *. If you give it an object it'll probably just print its address.

  3. #3
    Registered User
    Join Date
    Mar 2011
    Posts
    13

    Re: Problem with QString and QTextStream class

    So I need to convert QString to const char* with cast or with video.toLatin1().data ? What is the best solution for converting QString to char.
    Thanks!

  4. #4
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: Problem with QString and QTextStream class

    Generally: toAscii().data()

    Or toLatin1, depending on the contents of your original string.

Similar Threads

  1. Replies: 0
    Last Post: 2003-06-26, 12:20
  2. Problem with new class
    By jmorato in forum Symbian
    Replies: 1
    Last Post: 2003-06-18, 05:04

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×