Question: Here is the MWE:

```
\documentclass{article}
\usepackage[shortlabels]{enumitem}
\begin{document}
\begin{enumerate}[label={Q.\arabic*.}]
  \item This is 1
  \item This is 2
  \item This is 3A
  \item This is 3B
  \item This is 4
\end{enumerate}
\end{document}

```

How do I get labels to match the items details? So, it should Q.1., Q.2., Q.3.A, Q.3.B, Q.4, etc. instead of Q.1., Q.2., ..., Q.5., etc.?

Answer: 
If you don't mind doing the special cases semi-manually, you could do the following:

```
\documentclass{article}
\usepackage[shortlabels]{enumitem}

\newlength{\aw}
\settowidth{\aw}{A}

\begin{document}
\begin{enumerate}[label={Q.\arabic*.\hspace*{\aw}}]
  \item This is 1
  \item This is 2
  \addtocounter{enumi}{1}
  \item[Q.\arabic{enumi}A.] This is 3A
  \item[Q.\arabic{enumi}B.] This is 3B
  \item This is 4
  \item This is 5
\end{enumerate}
\end{document}

```

[![enter image description here](https://i.stack.imgur.com/ZFh5t.png)](https://i.stack.imgur.com/ZFh5t.png)
Here is a semi-automated way of constructing these lists. With the code below, you can use the commands

```
  \begin{MyList}
    \item This is 1
    \item This is 2
    \item* This is 3A
    \item* This is 3B\label{3B}
    \item This is 4
  \end{MyList}

```

to produce the list:

[![enter image description here](https://i.stack.imgur.com/WqzqN.png)](https://i.stack.imgur.com/WqzqN.png)

So, whenever `\item*` is used then a letter is added to the item number, with the item number increasing only if the last item was unstarred. You can still use `\item[label]` to override items labels if you wish with the caveat that the optional label will be ignored with `\item*[optional label]`.

Here is the full code, some explanations below:

```
\documentclass{article}
\usepackage[shortlabels]{enumitem}
\usepackage{xparse}

\let\realItem\item% save \item for use in \repeatingItem
\newif\ifRepeatingItem
\newcounter{repeatLabel}
\renewcommand\therepeatLabel{Q.\arabic{MyListi}\Alph{repeatLabel}.}
\NewDocumentCommand\repeatingItem{ so }{%
  \IfBooleanTF{#1}{%
     \ifRepeatingItem% need to stop enumi from incrementing
     \else\stepcounter{MyListi}\setcounter{repeatLabel}{0}% reset repeat label counter
     \fi%
     \refstepcounter{repeatLabel}% increment counter
     \realItem[\therepeatLabel]% print the label
     \RepeatingItemtrue%
     }{\IfValueTF{#2}{\realItem[#2]}{\realItem}%
     \RepeatingItemfalse%
  }%
}
\newlist{MyList}{enumerate}{1}% assuming no nesting
\setlist[MyList]{
    label=Q.\arabic*.,
    before=\let\item\repeatingItem,
    widest=Q.8A.
}

\begin{document}

  \begin{MyList}
    \item This is 1
    \item This is 2
    \item* This is 3A
    \item* This is 3B\label{3B}
    \item This is 4
  \end{MyList}

\end{document}

```

I have used `\newlist` to define a new `enumerate` like list, which I assume will not be nested -- it would be possible to allow nesting, but this is a little more complicated. Inside a `MyList` environment the `\item` command is really `\repeatingItem`, which uses some [xparse](https://www.ctan.org/pkg/xparse) magic to determine when a `*` is used.
Because the behaviour of `\item*` is different depending on whether the previous item was starred, I have defined a boolean `\ifRepeatingItem` to keep track of whether or not the last item was starred. Apart from this we just increment the various counters needed for the output.