I've done some coding using Qt and I need to list the code in a document. One of the advantages of Qt is the multiple template classes such as QList or QMap for example. I'm trying to get the correct syntax highlighting using minted, but can't seem to work out how.

Given all of the templates start with a Q is it possible to use regex to match these and highlight them as keywords? The idea comes from writing Qt in emacs, specifically Q[A-Z][A-Za-z]*.

Furthermore, is it possible to add other keywords, as Qt also uses SIGNAL, SLOT and Q_OBJECT among others? I know in listings it is possible using the emph option.

Example code from the Qt Website:

QMap<QString, int>::const_iterator i = map.constBegin();
while (i != map.constEnd()) {
    cout << i.key() << ": " << i.value() << endl;

closed as unclear what you're asking by TeXnician, Bobyandbob, Troy, Zarko, Sebastiano Aug 19 '18 at 19:25

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Related: tex.stackexchange.com/questions/18083. The best option is probably a custom lexer. – G. Poore May 6 '15 at 15:29
  • Thanks. I feel like it'll be more hassle than it's worth - I don't quite have the time to get my head around Pygments. – CircularRecursion May 6 '15 at 17:23
  • On an unrelated note, these identifiers are not keywords. It may make sense to highlight them but there are also arguments against that, for example the fact that nothing prevents the user from adding their own identifiers starting with Q that would not fit into the scheme of Qt classes. – Konrad Rudolph May 7 '15 at 1:40
  • Any news here? Have you found a solution? – TeXnician Dec 29 '17 at 18:05

Browse other questions tagged or ask your own question.