QGIS3 has a tool called 'gdal2tiles.py' which can generate map tiles, but currently, it only supports TMS, not XYZ. However, QGIS3 loads XYZ by default and requires checkbox for TMS, so it's better to convert TMS to XYZ.
The difference between TMS and XYZ is just the name of Y-coordinate, so renaming works well. tms2xyz.py is a script for that.