use this function:
{
if(s.isEmpty())
return;
QString sColor
= "<font color="+c.
name()+">";
while ( !theStream.atEnd() )
read_textEdit
->append
(QTime::currentTime().
toString() + " " + sColor
+theStream.
readLine());
//edLog->setParagraphBackgroundColor(edLog->paragraphs()-1,c);
QFile file( "[LOG FILE NAME].log" );
// Write the text to a file if ( file.open( IO_WriteOnly ) )
{
for(int i=0;i<m_log->paragraphs();i++)
stream << read_textEdit->text(i) << "\r\n";
}
file.close();
}
void WriteLog(QString s, QColor c)
{
if(s.isEmpty())
return;
QTextStream theStream(s,IO_ReadOnly);
QString sColor = "<font color="+c.name()+">";
while ( !theStream.atEnd() )
read_textEdit->append(QTime::currentTime().toString() + " " + sColor+theStream.readLine());
//edLog->setParagraphBackgroundColor(edLog->paragraphs()-1,c);
QFile file( "[LOG FILE NAME].log" ); // Write the text to a file
if ( file.open( IO_WriteOnly ) )
{
QTextStream stream( &file );
for(int i=0;i<m_log->paragraphs();i++)
stream << read_textEdit->text(i) << "\r\n";
}
file.close();
}
To copy to clipboard, switch view to plain text mode
this function write the string s to the read_textEdit member and a log file(you do not need to use this "file code" if you do not want log file)
each time you want to write to a log file or to the read_textEdit member call this function with any color you want
Bookmarks