Results 1 to 5 of 5

Thread: How to deal with very long QString?

  1. #1
    Join Date
    Sep 2009
    Location
    Surrey, BC, Canada
    Posts
    110
    Thanks
    1
    Thanked 2 Times in 1 Post
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default How to deal with very long QString?

    Hi, all:

    I'm trying to write a single about() function, with only a QMessageBox as follows:

    Qt Code:
    1. QMessageBox::information(this,
    2. "My System",
    3. "line 111111111111111111111111111111 \n"
    4. "line 222222222222222222 \n"
    5. "line 33333333333333333333333333333333333" );
    To copy to clipboard, switch view to plain text mode 

    However, I seriously don't like the above code style because I need to do \n at the end of every line, which is so inconvenient. I prefer all the info in the 3rd parameter in the above code can be summarized into a single quote instead of 3 quote, and better without \n . Can anybody help please?



    Best Regards
    Pei
    Welcome to Vision Open
    http://www.visionopen.com

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to deal with very long QString?

    Help with what? If you want to type it all as a single string without breaks then go right ahead.

  3. #3
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: How to deal with very long QString?

    You may create a list a QStringList, and merge then with "\n" while setting it on to diplay widget.
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

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

    Default Re: How to deal with very long QString?

    Quote Originally Posted by Santosh Reddy View Post
    You may create a list a QStringList, and merge then with "\n" while setting it on to diplay widget.
    This will still require many strings :-) But as was already said one can put everything in one strong as well. Strings in C/C++ can span across lines.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: How to deal with very long QString?

    This will still require many strings :-) But as was already said one can put everything in one strong as well. Strings in C/C++ can span across lines.
    As I usderstand OP, they require to speficy multi-line (with line breaks), but does not want to type string with "\n" at the end. C/C++ will just concatinate the strings (will not insert \n).
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

Similar Threads

  1. Can Qt deal with Excel?
    By Patrick Sorcery in forum Newbie
    Replies: 3
    Last Post: 9th January 2013, 05:48
  2. How to deal with foreign key in Qt
    By sjyzhxw in forum Qt Programming
    Replies: 3
    Last Post: 25th May 2012, 09:31
  3. qDebug() and long long int on WIN
    By iw2lsi in forum Qt Programming
    Replies: 3
    Last Post: 21st March 2012, 05:47
  4. Replies: 2
    Last Post: 16th May 2010, 17:23
  5. Replies: 12
    Last Post: 23rd March 2007, 09:23

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.