You could try this:
1) Create a simple style in Layer properties, then save it to an export file using the save button. These are in the form:
value, R, G, B, Alpha, label
2) Use r.category in the grass (6 or 7) toolbox of the processing module. This should provide a list of raster values. Copy these values. You can use r.quantile for continuous data.
3) Open the export file you saved earlier in a text editor (e.g. notepad++ on windows, loads of choice on linux). Paste the values and reformat to suit.
@Stephane
3a) For discrete values, you can set the alpha to 0, or delete or comment out (using # at the start of the line) any data you don't want to display in the category file.
3b) For continuous values, create a row for the start value and another for the end value. Set the alpha for both to 0.
4) For example, say you have created three files:
categories.txt - output of r.category, copy and paste, add two blank lines at the top. Total length 1 column. Check the number of unique values, and make a style with the same number of entries in QGIS.
colours.txt - a QGIS Generated Color Map Export File with the colours you like. Total length 6 columns.
labels.txt - file with the labels you want, add two blank lines at the top. Total length 1 column.
Use a spreadsheet to merge the files and save as a csv. Open this in QGIS.
Alternatively, on the command line (bash or msys):
paste -d, categories.txt colours.txt labels.txt |cut -d, -f 1,3-6,8 > new_style.txt
See also:
https://pvanb.wordpress.com/2014/02/05/creating-a-qgis-color-map-from-text-file/
Advanced colour palette for raster data