Results 1 to 9 of 9

Thread: A collection of letters and numbers

  1. #1
    Join Date
    Jul 2010
    Posts
    71
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default A collection of letters and numbers

    Hello

    I want to print a set of numbers and letters.
    How can I do that, I want a simple example.

  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: A collection of letters and numbers

    Use any of the print or output stream functions.

    Google for printf or cout, or check the qt docs for qdebug or qtextstream(stdout)

  3. #3
    Join Date
    Jul 2010
    Posts
    71
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: A collection of letters and numbers

    Quote Originally Posted by tbscope View Post
    Use any of the print or output stream functions.

    Google for printf or cout, or check the qt docs for qdebug or qtextstream(stdout)
    I using Qt Creator

  4. #4
    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: A collection of letters and numbers

    Do you have a specific question?

    This is basic C++ and hasn't anything to do with Qt.

    Here's an example, and I'm being very very generous here.

    Qt Code:
    1. #include <stdio.h>
    2.  
    3. int main(int argc, char *argv[])
    4. {
    5. printf("Hello world!\n");
    6.  
    7. return 0;
    8. }
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Jul 2010
    Posts
    71
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: A collection of letters and numbers

    But I want to print numbers and letters inside the For loop
    Like,
    Qt Code:
    1. void MainWindow :: print()
    2. {
    3. int x;
    4. for(int i=0; i<100 ; i++)
    5. {
    6. // <-- Here's what I put to print the " Number = x"
    7. x++;
    8. }
    9.  
    10. }
    To copy to clipboard, switch view to plain text mode 


    as
    Last edited by NewLegend; 8th September 2010 at 19:22.

  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: A collection of letters and numbers

    Do you want to display the text in a text editor or a label?

    If so, use something like:

    Qt Code:
    1. QString("Number = %1").arg(x);
    To copy to clipboard, switch view to plain text mode 
    Use the setText or setPlainText function of the text edit or label

  7. #7
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: A collection of letters and numbers

    Qt Code:
    1. void MainWindow :: print()
    2. {
    3. int x;
    4. for(int i=0; i<100 ; i++)
    5. {
    6. // <-- Here you can use the print just like outside of for
    7. cout << x << ' '; //print with a space between
    8. //or
    9. qDebug() << 100; //
    10. //or even printf
    11. x++;
    12. }
    13.  
    14. }
    To copy to clipboard, switch view to plain text mode 

    Just make sure that you include the necessary header file.

    And don't forget to initialize x

  8. #8
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: A collection of letters and numbers

    Sorry i skipped the picture in the first place

    To replicate the interface within that picture you will need to use widgets and layouts
    Like QLabel to just display some text, or QSpinBox to display a spinbox where the user can select a value
    And there are some QPushButton, QLineEdit and a QTextEdit

    LE: link to tutorials that should give you an easier start with Qt, if you don't understand something you can ask more specific questions on the forum
    Last edited by Zlatomir; 8th September 2010 at 19:46. Reason: added a link to Qt tutorials

  9. #9
    Join Date
    Jul 2010
    Posts
    71
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: A collection of letters and numbers

    Now used textBrowser
    But it takes a lot of time for the exit of the results
    Qt Code:
    1. void MainWindow :: print()
    2. {
    3.  
    4. for(int i=0; i<200 ; i++)
    5. {
    6. ui->textBrowser->setPlainText(ui->textBrowser->toPlainText() + "Hiiiii " + "\n" );
    7.  
    8. }
    9.  
    10. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Garbage collection
    By Septi in forum Qt Programming
    Replies: 5
    Last Post: 6th July 2010, 14:13
  2. question about garbage collection
    By Dumbledore in forum Qt Programming
    Replies: 4
    Last Post: 18th December 2007, 22:08
  3. Garbabe Collection
    By coderbob in forum Newbie
    Replies: 3
    Last Post: 19th November 2007, 21:02
  4. Reading umlaut letters from sqlite database
    By Djony in forum Qt Programming
    Replies: 11
    Last Post: 17th November 2006, 10:30
  5. lib using Image Collection
    By bitChanger in forum Qt Programming
    Replies: 4
    Last Post: 25th July 2006, 17:30

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.