Found the solution. Added this to the end of the function and now it the partitions filesystems are correctly formatted:
newBootFs->create(*rootReport, bootDeviceNode); newRootFs->create(*rootReport, rootDeviceNode);Also I could delete this:
if (devicePartitionTable->typeName() == "gpt") { qDebug() << "Setting partition type for GPT table"; newBootPartition->setType("C12A7328-F81F-11D2-BA4B-00A0C93EC93B"); // GPT GUID for EFI System Partition newRootPartition->setType("0FC63DAF-8483-4772-8E79-3D69D8477DE4"); // GPT GUID for Linux Filesystem } else if (devicePartitionTable->typeName() == "msdos") { qDebug() << "Setting partition type for MBR table"; newBootPartition->setType("0xEF"); // MBR type code for EFI System Partition newRootPartition->setType("0x83"); // MBR type code for Linux Filesystem }