title: 'qt' best approach to Bold or change the size of QPlainTextEdit
body: <p>I am new in 'qt' programing and I am writing a simple text editor using 'QPlainTextEdit' .</p>
  
  <p>I already asked my question in "<a href="http://qt-project.org/forums/viewthread/27343/" rel="nofollow">qt forum</a>" but didn't get a response .</p>
  
  <p><em>I have two 'QPushButton' to bold and italicize but the problem is that they edit the whole text not the selected ones .</em></p>
  
  <p><em>There is the same problem when I try to change the font size</em></p>
  
  <p>In Main I have :</p>
  
  <pre><code> this-&gt;B_flag=false;
   this-&gt;I_flag=false;
   this-&gt;Font_Size=15;
   QFont newFont("Courier", this-&gt;Font_Size, QFont::Normal, false);
   textEdit-&gt;setFont(newFont);
  </code></pre>
  
  <p>In Method :</p>
  
  <pre><code> void MainWindow::setItalic()
   {
   QFont newFont("Courier", this-&gt;Font_Size);
   if(this-&gt;I_flag==false){
       newFont.setItalic(true);
       this-&gt;I_flag=true;
   }
   else{
       newFont.setItalic(false);
       this-&gt;I_flag=false;
   }
   newFont.setBold(this-&gt;B_flag);
   textEdit-&gt;setFont(newFont);
   }
  </code></pre>
  
  <p>I have a Similar function to set Bold.</p>
  
  <p>Similar approch to change size:</p>
  
  <pre><code> void MainWindow::setNormal()
   {
   this-&gt;Font_Size=25;
   QFont newFont("Courier", Font_Size);
   newFont.setBold(this-&gt;B_flag);
   newFont.setItalic(this-&gt;I_flag);
   textEdit-&gt;setFont(newFont);
   }
  </code></pre>
  
  <p>This is the screenshot :</p>
  
  <p>s22.postimg.org/b28r9tjap/before.jpg</p>
  
  <p>s8.postimg.org/urxj51s9x/after.jpg</p>
  
  <p>and The whole code just in case :</p>
  
  <p><a href="https://www.dropbox.com/sh/g2hq0dmk9768ps5/v_3kUsxdQl" rel="nofollow">https://www.dropbox.com/sh/g2hq0dmk9768ps5/v_3kUsxdQl</a></p>
  
  <p>It would be great if someone could help.</p>