OutputDevice console; console.writeAttr("\033[1;31m"); // set text color to bold red console.write("Hello, world!"); console.writeAttr("\033[0m"); // reset text color to default
OutputDevice file("output.txt"); file.writeAttr(""); // set text to italic file.write("This is italicized text."); file.writeAttr(""); // reset text to defaultIn this example, the writeAttr function is used to set the text to italic with the HTML tag ``. The write function is then used to output the text "This is italicized text." to a file named "output.txt". Finally, the writeAttr function is used again to reset the text to the default with the closing HTML tag ``. Overall, these examples demonstrate how the OutputDevice writeAttr function can be used to format text output in various ways. The Qt library package is required to use this function.