Your SQL is incorrect. Create the table and then insert the rows.
QSqlQuery query("CREATE TABLE tasks (taskId INTEGER, PRIMARY KEY(taskId))");
; //< Handle error - table couldn't be created
query.prepare("INSERT INTO tasks (taskId) VALUES (:id)");
// From here on you can have multiple calls to the same piece of code to insert multiple rows
; //< Handle error - can't insert row
Additionally, I advise you to create the table once and for all. Then just fill it up, instead of trying to create it on every row insertion.