[Tex/LaTex] Custom name of listing in list of listings with minted not working

germanlistingslstlistingmintedtable of contents

I am using the minted package to highlight source code and also to add a list of listings. My code already looks like it should:

\begin{listing}[hb]
    \inputminted[frame=single,linenos]{c}{code/hello_world.c}
    \caption{Hello World in C}
    \label{hello_world_c}
\end{listing}

Code snippet, working as intended

I used the following commands to change the autoref name and the caption name:

\providecommand*{\listingautorefname}{Qc.}
\addto\captionsngerman{\renewcommand{\listingscaption}{Qc.}}

I also removed the chapter counter in the list of listings with the following commands:

\usepackage{chngcntr}
\counterwithout{figure}{chapter} 
\counterwithout{table}{chapter}
\counterwithout{listing}{chapter}

Now I insert the list of listings like this:

\addcontentsline{toc}{chapter}{Quellcodeverzeichnis}
\renewcommand{\listoflistingscaption}{Quellcodeverzeichnis}
\listoflistings
\clearpage

And my list of listings looks like this:

The actual list of listings

But instead I would like it to look like this:

List of listings as it should look like

I already tried inserting the name with
\renewcommand{\cftlistingpresnum}{Qc.~}

But I get the following error: LaTeX Error: \cftlistingpresnum undefined.

I also tried using \usepackage[newfloat]{minted} but then the commands that worked before are undefined:

LaTeX Error: \listingscaptionundefined.
LaTeX Error: \listoflistingscaptionundefined.

I use ShareLaTeX for compiling my files.
I read that the babel package might cause some problems, here is a list of packages I also use:

\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage[chapter]{minted}
\usepackage{etoolbox}

\usepackage[decimalsymbol=comma]{siunitx}
\usepackage[german,algosection,boxed]{algorithm2e}
\usepackage[onehalfspacing]{setspace}
\usepackage[titles]{tocloft}
\usepackage{caption}
\usepackage{enumitem}
\usepackage{graphics}
\usepackage{graphicx}
\usepackage{here}
\usepackage{hyperref}
\usepackage{pdflscape}
\usepackage{pstricks}
\usepackage{subcaption}
\usepackage{thmbox}

Edit: Here is my minimal working example:

\documentclass{scrreprt}

\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}

\usepackage[chapter]{minted}
\usepackage{etoolbox}
\usemintedstyle{vs}

\usepackage[titles]{tocloft}
\usepackage{hyperref}
\usepackage{caption}
\usepackage{subcaption}

% ----------------------------------------------------------------
% Settings of Quellcodeverzeichnis
% ----------------------------------------------------------------
\usepackage{chngcntr}
\counterwithout{listing}{chapter}

% Doesn't work: LaTeX Error: \cftlistingpresnum undefined.
% \renewcommand{\cftlistingpresnum}{Qc.~}

\addto\captionsngerman{\renewcommand{\listingscaption}{Qc.}}
\providecommand*{\listingautorefname}{Qc.}

% ----------------------------------------------------------------
% Table of contents
% ---------------------------------------------------------------- 
\begin{document}
\tableofcontents
\clearpage

% ----------------------------------------------------------------
% Quellcodeverzeichnis
% ----------------------------------------------------------------
\phantomsection
\addcontentsline{toc}{chapter}{Quellcodeverzeichnis}
\renewcommand{\listoflistingscaption}{Quellcodeverzeichnis}
\listoflistings
\clearpage

% ----------------------------------------------------------------
% Content
% ----------------------------------------------------------------
\chapter{LaTeX-Template}
\label{ch:anhang}

My Hello World C program is right here: \autoref{hello_world_c}

\begin{listing}[hb]
\begin{minted}[frame=single,linenos]{c}
#include<stdio.h>

int main() {
    printf("Hello World\n");
    return 0;
}
\end{minted}
\caption{Hello World in C}
\label{hello_world_c}
\end{listing}
\clearpage


\end{document}

Any suggestions would be greatly appreciated.

Best Answer

I was able to solve my problem with the help of this answer: Customizing the list of listings from minted

Here is my result:

\documentclass{scrreprt}

\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}

\usepackage[titles]{tocloft}
\newlistof{listing}{lol}{Quellcodeverzeichnis}

\usepackage[newfloat]{minted}
\usemintedstyle{vs}
\usepackage{caption}

\usepackage{hyperref}
\usepackage{subcaption}

% ----------------------------------------------------------------
% Settings of Quellcodeverzeichnis
% ----------------------------------------------------------------
\usepackage{chngcntr}
\counterwithout{listing}{chapter}

\newenvironment{code}{\captionsetup{type=listing}}{}
\SetupFloatingEnvironment{listing}{%
    name={Qc.},
    fileext=lol}

\renewcommand{\cftlistingpresnum}{Qc.~}
\setlength{\cftlistingnumwidth}{2cm}

\begin{document}

% ----------------------------------------------------------------
% Table of contents
% ---------------------------------------------------------------- 
\tableofcontents
\clearpage

% ----------------------------------------------------------------
% Quellcodeverzeichnis
% ----------------------------------------------------------------
\phantomsection
\addcontentsline{toc}{chapter}{Quellcodeverzeichnis}
\listoflistings
\clearpage

% ----------------------------------------------------------------
% Content
% ----------------------------------------------------------------
\chapter{LaTeX-Template}
\label{ch:anhang}

My Hello World C program is right here: \autoref{hello_world_c}

\begin{listing}[hb]
\begin{minted}[frame=single,linenos]{c}
#include<stdio.h>

int main() {
    printf("Hello World\n");
    return 0;
}
\end{minted}
\caption{Hello World in C}
\label{hello_world_c}
\end{listing}
\clearpage

\end{document}