latex中使用listings显示代码

时间:2020-12-22 06:09:49

\documentclass[12pt,a4paper]{article}
\usepackage{ctex}
\usepackage{listings}
\usepackage{xcolor}
\begin{document}
Qt中的等级观念

\lstset{language=c++,breaklines=true,numbers=left,xleftmargin=0em,xrightmargin=0em}
\begin{lstlisting}

/*!
\internal

File was visible before, but now should NOT be

*WARNING* this will change the visible count
*/
void QFileSystemModelPrivate::removeVisibleFile(QFileSystemNode *parentNode, int vLocation)
{
Q_Q(QFileSystemModel);
if (vLocation == -1)
return;
QModelIndex parent = index(parentNode);
bool indexHidden = isHiddenByFilter(parentNode, parent);
if (!indexHidden)
q->beginRemoveRows(parent, translateVisibleLocation(parentNode, vLocation), translateVisibleLocation(parentNode, vLocation));
parentNode->children.value(parentNode->visibleChildren.at(vLocation))->isVisible = false;
parentNode->visibleChildren.removeAt(vLocation);
if (!indexHidden)
q->endRemoveRows();
}

 

  


\end{lstlisting}

\end{document}