Results 1 to 7 of 7

Thread: Listing points in TextEdit

  1. #1
    Join Date
    Jun 2011
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Listing points in TextEdit

    I've got a console program representing points on the plane and now i want to the window program (on linux). I have done button "List points" and i want it to write them in QPlainTextEdit (unless there isn't a better option). In console program i listed this points using function:
    Qt Code:
    1. cout << set1
    To copy to clipboard, switch view to plain text mode 
    Is it possible to do it in qt?

  2. #2
    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: Listing points in TextEdit

    Yes it is possible in Qt.

    This should be simple, if you know how to create a basic QWidget based GUI, and add standard display widgets to it

  3. #3
    Join Date
    Jun 2011
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Listing points in TextEdit

    I'm beginner and i don't know how to do that, but i have to this today :/
    I forgot to attach operator << overloading:
    Qt Code:
    1. std::ostream& operator<< (std::ostream& os, const Set& st)
    2. {
    3. if (st.size() == 0) os << "NULL";
    4. for (long i=0; i<st.size(); i++)
    5. {
    6. if ((i%5 == 0)) os << std::endl;
    7. os << st[i] << ", ";
    8. }
    9. os << std::endl;
    10. return os;
    11. }
    To copy to clipboard, switch view to plain text mode 

    Could you help me with it?

  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: Listing points in TextEdit

    If this is a school project then we can't help you much, otherwise you will not learn. I can give you a hint that dumping those points to a text edit box is not better than dumping them to a console. It would be more interesting if you drawn a graphical representation of those points or at least if you displayed the points in a list (such as QListWidget).
    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
    Jun 2011
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Listing points in TextEdit

    It's not a school project. I'm helping my friend with c++ and i'm stuck only with it... He has tomorrow a test and i have to explain it to him.
    This points have to be listed, not drawn on the plot.

  6. #6
    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: Listing points in TextEdit

    Follow this post, it might of some use to you
    http://www.qtcentre.org/threads/4153...played-at-once

  7. #7
    Join Date
    Jun 2011
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Listing points in TextEdit

    Thanks.
    I've made something like that
    Qt Code:
    1. void Surface::write(const Set& st)
    2. {
    3. QString output;
    4. for (long i=0; i<st.size(); i++)
    5. {
    6. if (i%5 == 0) {
    7. Main->appendPlainText(output);
    8. output.clear();
    9. }else{
    10. output.append(QString::number(st[i]) + ", ");
    11. }
    12. }
    13. }
    To copy to clipboard, switch view to plain text mode 
    and put it into set.cc (supporting class Set from set.h) and i've got an error:
    Qt Code:
    1. /home/matthew/Dewsktop/QT Project/QT-build-desktop/../QT/Set.cc:176: error:no matching function for call to ‘QString::number(Surface)’
    To copy to clipboard, switch view to plain text mode 

    What should i do to get rid of that error?

Similar Threads

  1. Listing a column of a table to a QListWidget
    By Luc4 in forum Qt Programming
    Replies: 1
    Last Post: 2nd October 2010, 20:21
  2. Listing files by filter on Macbook
    By dwarnold45 in forum Newbie
    Replies: 2
    Last Post: 30th March 2010, 04:01
  3. listing derectory contents
    By ramamurthy.kv in forum Qt Programming
    Replies: 9
    Last Post: 5th May 2008, 19:59
  4. listing the files that has been uploaded to postgres
    By aekilic in forum Qt Programming
    Replies: 2
    Last Post: 10th September 2007, 10:43
  5. class functions are not listing [ in VC++ editor]
    By joseph in forum Qt Programming
    Replies: 8
    Last Post: 4th April 2007, 11:43

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.