Results 1 to 9 of 9

Thread: insert number to qtextEdit

  1. #1
    Join Date
    Sep 2010
    Posts
    16
    Qt products
    Qt4
    Platforms
    Windows

    Default insert number to qtextEdit

    Hi

    How Can insert number to qtextEdit ??

  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: insert number to qtextEdit

    No need to yell.

    What's wrong with QTextEdit::setPlainText()?

  3. #3
    Join Date
    Aug 2009
    Location
    Belgium
    Posts
    310
    Thanks
    10
    Thanked 31 Times in 25 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: insert number to qtextEdit

    And to put a number in it, use e.g. :

    Qt Code:
    1. ui->myEdit->setPlainText( QString::number( 123 ));
    To copy to clipboard, switch view to plain text mode 

    Regards,
    Marc

  4. #4
    Join Date
    Sep 2010
    Posts
    16
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: insert number to qtextEdit

    Now I want using QlineEdit
    as,
    Qt Code:
    1. ui->lineEdit->textEdited( QString::number( 123 ) );
    To copy to clipboard, switch view to plain text mode 

    But i see this error,
    error: 'void QLineEdit::textChanged(const QString&)' is protected

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

    Default Re: insert number to qtextEdit

    textEdited() is a signal.
    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.


  6. #6
    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: insert number to qtextEdit

    How about you try to describe what you are trying to achieve overall (in English not code) rather than firing off queries about each line of your code out of context. It strikes me that you might be better off with a QLineEdit or a QSpinBox if you are going to be soliciting numbers from the user.

  7. #7
    Join Date
    Sep 2010
    Posts
    16
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: insert number to qtextEdit

    I want a way to:
    Get values from the user.
    Put the values in the box.

    Do you use the QLineEdit or qtextEdit

  8. #8
    Join Date
    Sep 2010
    Posts
    16
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: insert number to qtextEdit

    For, Get values from the user:
    Qt Code:
    1. int x = ui->textEdit->toPlainText().toInt(&ok,10);
    2. //Or
    3. QString x = ui.textEdit->toPlainText();
    To copy to clipboard, switch view to plain text mode 

    and for, Put the values in the box:
    Qt Code:
    1. ui->textEdit->setPlainText( QString::number( 123 ));
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: insert number to qtextEdit

    Use QSpinBox instead of QTextEdit. QTextEdit is for multi-line text, that's not what you want.
    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.


Similar Threads

  1. insert image at the bottom of QTextEdit
    By Cortex in forum Qt Programming
    Replies: 12
    Last Post: 24th October 2009, 15:22
  2. how can I find number of lines in QTextedit ?
    By newplayer in forum Newbie
    Replies: 10
    Last Post: 14th August 2008, 23:02
  3. QTextEdit slow to insert text
    By thomaspu in forum Qt Programming
    Replies: 4
    Last Post: 10th January 2008, 12:05
  4. Line Number - QTextEdit...???
    By deepusrp in forum Qt Programming
    Replies: 2
    Last Post: 15th May 2007, 16:34
  5. How to change paragraph number in QTextEdit?
    By Sarma in forum Qt Programming
    Replies: 2
    Last Post: 10th March 2006, 09:42

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
  •  
Qt is a trademark of The Qt Company.