QPlaintTextEdit and setFont to selected Char



  • Hi, how can setFont() to selected char in QPlainTextEdit (no to all QPlainTextEdit) ???



  • are you test it ?
    @
    setCurrentCharFormat()
    @



  • setCurrentCharFormat () it's work thx ;)
    i have next question, if i want save all text inside QPlainTextEdit to file and load this text(with this font), then i have make big array of QTextCharFormat and save this TextCharFormat for each char in QPlainTextEdit, or is better way ??



  • you are welcome.
    no,if you save this text with current font,and read it and set it as plain text , it works without any problem with your formats.



  • But how save with current font ??
    Before i do that:
    Save-
    QTextStream < QPlainTextEdit->toPlainText();
    Load-
    QPlainTextEdit->setPlainText(QTextStream.readAll());



  • this is works,
    @
    //for save :
    ui->plainTextEdit->toPlainText();
    //this is save the texts with formats.
    @



  • it's didnt work ;(

    Save
    [code]
    void PageItem::save()
    {

    if( haveFile )
    {
        if( !isSaved )
        {
            if( File->open(QIODevice::WriteOnly | QIODevice::Text ))
            {
                QTextStream t_Stream(File);
                t_Stream <&lt; PlainTextEdit-&gt;toPlainText();
    
                File->close();
            }
    
            isSaved = true;
    
        }
    }else
    {
        QFileDialog t_Dialog(0);
        saveAs(t_Dialog.getSaveFileName(0,"Save"));
    }
    

    }
    [/code]

    Open
    [code]
    if(File->open(QIODevice::ReadOnly | QIODevice::Text))
    {
    QTextStream stream(File);

        PlainTextEdit->setPlainText(stream.readAll());
        File->close();
    }
    

    [/code]

    if i save with font after open font is default (not like after save)



  • Pablik2005 , I thi* nk you want to save your QPlainTextEdit content with format to rtf file!
    but,rtf files and it's formats just for Microsoft ;Not Standard For All Platforms!

    if you want to save your custom text format, you can save it and open it by HTML tags.
    Convert it to HTML or use QTextEdit as this :
    @
    //for open
    ui->textEdit->setHtml("<b>Bold Text</b>");

    //for save
    ui->textEdit->toHtml();
    @



  • and if you want to design a text editor , "see this link ":http://qt-apps.org/content/show.php/GoodWord?content=133968



  • ok thx for help


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.