I'd like to make QComboBoxes with right-justified text. The following does most of what I want to an existing box
Qt Code:
  1. #include <QComboBox>
  2. #include <QLineEdit>
  3. void rightJustCombo(QComboBox *combo)
  4. {
  5. combo->setEditable(true);
  6. combo->lineEdit()->setAlignment(Qt::AlignRight);
  7. for (int i=0; i<combo->count(); i++)
  8. combo->setItemData(i, Qt::AlignRight, Qt::TextAlignmentRole);
  9. combo->lineEdit()->setReadOnly(true);
  10. }
To copy to clipboard, switch view to plain text mode 
What's not quite right is that the pulldown text is farther right than the lineEdit text by the width of the pulldown arrow. Is there a way to line up the text?