This isn't perfect, but it's about the only thing I could find that approximates what you're asking.
- Adjust the symbology of
lines_layer to your liking. In order for the next step to work, make sure that your symbology is based on Map Units.

In the Raster tools toolbox, select the tool Convert map to raster. Set the parameters as follows and run the tool:
- Extent: Slightly larger than
lines_layer, so as not to clip the output.
- Map units per pixel: This will depend on the symbol size of your line. In my example, I chose a value that was 5% of the line width.
- Make background transparent: checked
- Single layer to render:
lines_layer
Below is one line dash in transparent yellow, with the rasterized version of the same dash in B/W.

- Run Polygonize (Raster to Vector), found in GDAL > Raster conersion, on your newly-created raster.
If you've got any angled lines, you'll end up with a bunch of jagged polygons, as shown below.

- You'll need to run a tool to straighten out the edges of these new polygons. There are a couple of things you can do:
- Simplify. You may need to toy around with the
tolerance parameter a bit, but I had satisfactory results with 10% of the line width. Some dashes may have more than 4 vertices, however, resulting in some polygons being misshapen.
- Oriented Minimum Bounding Box. This method results in polygons which are all perfectly orthogonal, but each one may be at a slightly different angle from its neighbors.
Below are the different vector stages of this process. Which you prefer is probably dependent on what exactly you need these dash polygons for.
