title: How can I know which printer is selected
body: <p>I have a program with the typical printer dialog (made with QPrintDialog from Qt5.1) where you can select the printer you want from a list. Let's say you have printerA (selected by default), printerB, printerC and printerD. I have a problem with printerD so when the user selects it I want to do something (maybe show a popup message or maybe dissable some buttons).</p>
  <p>I've been looking for how to know if printerD is selected but couldn't find it. I've search in <a href="https://doc.qt.io/qt-5/qprinter.html" rel="nofollow noreferrer">QPrinter</a>, <a href="https://doc.qt.io/qt-5/qprinterinfo.html" rel="nofollow noreferrer">QPrinterInfo</a>, <a href="https://doc.qt.io/qt-5/qprintdialog.html" rel="nofollow noreferrer">QPrintDialog</a> and <a href="https://doc.qt.io/qt-5/qdialog.html#done" rel="nofollow noreferrer">QDialog</a> and I couldn't find it. Also I've found <a href="https://stackoverflow.com/questions/59468287/qt-how-can-i-pick-default-printer-and-disable-the-rest-of-them-in-qprinterdialo">this</a> here which I though it could help me but the answer only tells you how to set the default one.</p>
  <p>If you don't know which dialog I am talking about, it's the same from <a href="https://stackoverflow.com/questions/59468287/qt-how-can-i-pick-default-printer-and-disable-the-rest-of-them-in-qprinterdialo">here</a>.</p>
  <p>I also was thinking if this list may be a QListWidget Class but if it was that, i 'don't know how to get it.</p>
  <p>So my question is: How may I know which is the printer selected in any moment of this PrinterDialog life? (While showing up).</p>
  <p>Also, I want to add, that I tried to dissable the button for the printer which gives me error with the next code but the QList is empty so I can't reach the Print or Preferences Button to dissable it I don't know why:</p>
  <pre><code> QList&lt;QPrinterInfo&gt; info_list = QPrinterInfo::availablePrinters();
   foreach(QPrinterInfo info, info_list)
   {
       if (info.state() == 3) // the printer gives error
       {
          QList&lt;QPushButton *&gt; allButtons = printDialog.findChildren&lt;QPushButton *&gt;();
  
         for (int i = 0; i &lt; allButtons.size(); i++) 
         {
            if (allButtons.at(i)-&gt;text().contains(&quot;Print&quot;) || allButtons.at(i)-&gt;text().contains(&quot;Preferences&quot;))
            {
             allButtons.at(i)-&gt;setDisabled(true);
            }
         }
       }
    }
  </code></pre>
  <p>Thank you in advance.</p>