Results 1 to 8 of 8

Thread: display in text browser

  1. #1
    Join Date
    Dec 2010
    Posts
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Unhappy display in text browser

    I am noob in QT as well as C++. Rite now I am trying to display value of iter->second but its not working. Here is the small piece of code
    Qt Code:
    1. multimap<string, string>::iterator iter;
    2.  
    3. iter = findFile.find(fileToFind);
    4.  
    5. if ( iter != findFile.end() )
    6. {
    7. do
    8. {
    9. string temp = iter->second;
    10. QString str;
    11. str.fromStdString(temp);
    12. ui->textBrowser->setText(str);;
    13. cout << iter->first << " [DIR] " << iter->second << endl;
    14. iter++;
    15. }while (iter != findFile.upper_bound ( fileToFind ) );
    16. }
    To copy to clipboard, switch view to plain text mode 
    Please help me out
    Last edited by mecrazycoder; 12th December 2010 at 19:13. Reason: for adding full code

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: display in text browser

    You need to convert it from a number to a string.
    Check out the QString documentation, specifically something like QString::number or the QString arg(...) function.

  3. #3
    Join Date
    Dec 2010
    Posts
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: display in text browser

    Thanks for ur response. But I cant able to figure out the problem. So if possible can you please edit my code

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

    Default Re: display in text browser

    'fromStdString' is static method, so you use it like so:

    Qt Code:
    1. QString qstr = QString::fromStdString(str);
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Dec 2010
    Posts
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: display in text browser

    Quote Originally Posted by squidge View Post
    'fromStdString' is static method, so you use it like so:

    Qt Code:
    1. QString qstr = QString::fromStdString(str);
    To copy to clipboard, switch view to plain text mode 
    Great it worked. Now i want to display results in text browser. But the problem I am facing is text browser display only the last result so can you please tell me how to populate all results(each result per line) in populate. How to integrate text browser with scroll bar. Tanx in advance

  6. #6
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: display in text browser

    Sorry, I thought second was a number (seconds).

  7. #7
    Join Date
    Jan 2010
    Location
    Perth, Australia
    Posts
    37
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: display in text browser

    Quote Originally Posted by mecrazycoder View Post
    But the problem I am facing is text browser display only the last result so can you please tell me how to populate all results(each result per line) in populate. How to integrate text browser with scroll bar. Tanx in advance
    The documentation for QTextBrowser is at http://doc.trolltech.com/4.7/qtextbrowser.html, and you can find all its methods here. Also, since QTextBrowser inherits QTextEdit, you can also use the methods in http://doc.trolltech.com/4.7/qtextedit.html.

    Anyway, setText() removes old text before adding new ones. To add text without removing the old ones, use append().

    If I'm not mistaken, the QTextBrowser should automatically have a scroll bar.

  8. #8
    Join Date
    Dec 2010
    Posts
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: display in text browser

    Thank you all for wonderful guidance

Similar Threads

  1. Demo Browser doesn't display jpeg, gif
    By dmt0 in forum Qt for Embedded and Mobile
    Replies: 3
    Last Post: 17th January 2011, 11:59
  2. Demo Browser cannot display jpeg or gif
    By stmk in forum Newbie
    Replies: 10
    Last Post: 23rd October 2010, 16:56
  3. I don't get expected output in text browser
    By NewLegend in forum Qt Programming
    Replies: 14
    Last Post: 25th July 2010, 09:21
  4. Problem while using Text browser
    By yuvaraj.yadav in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2009, 13:41
  5. Text Browser Link Question
    By taylor34 in forum Qt Programming
    Replies: 2
    Last Post: 20th June 2006, 19:54

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.