Post 1 of 2 due to length... Question in part 2 of 2...
Hello,
I am using Qt Creator 1.2.1, with Qt 4.5.2 on Windows Vista x32. I have a MySQL database created with MySQL Workbench v5.2.16.

I have been trying to get a cpp class completed to access 1 of the tables in the db and have run into an issue with the add record algorithm. Basically, I can successfully navigate the records in the table, but on adding a record, if I navigate away the model submits a copy of the record I nav'd to. For example:

tEmployees:
simple table with 2 related fields for department and status
Qt Code:
  1. CREATE TABLE IF NOT EXISTS `timeDB`.`tEmployees` (
  2. `idtEmployees` INT NOT NULL AUTO_INCREMENT ,
  3. `empNameCode` VARCHAR(45) NOT NULL ,
  4. `empFirstName` VARCHAR(50) NULL ,
  5. `empLastName` VARCHAR(80) NULL ,
  6. `tDepartment_idtDepartment` INT NOT NULL ,
  7. `tStatus_idtStatus` INT NOT NULL ,
  8. `empStartDate` DATETIME NOT NULL ,
  9. PRIMARY KEY (`idtEmployees`) ,
  10. INDEX `fk_tEmployees_tDepartment` (`tDepartment_idtDepartment` ASC) ,
  11. INDEX `fk_tEmployees_tStatus` (`tStatus_idtStatus` ASC) ,
  12. CONSTRAINT `fk_tEmployees_tDepartment`
  13. FOREIGN KEY (`tDepartment_idtDepartment` )
  14. REFERENCES `timeDB`.`tDepartment` (`idtDepartment` )
  15. ON DELETE NO ACTION
  16. ON UPDATE CASCADE,
  17. CONSTRAINT `fk_tEmployees_tStatus`
  18. FOREIGN KEY (`tStatus_idtStatus` )
  19. REFERENCES `timeDB`.`tStatus` (`idtStatus` )
  20. ON DELETE NO ACTION
  21. ON UPDATE CASCADE)
  22. ENGINE = InnoDB
To copy to clipboard, switch view to plain text mode 

tDepartment:
(contains fk links for dept id in employee table)
Qt Code:
  1. CREATE TABLE IF NOT EXISTS `timeDB`.`tDepartment` (
  2. `idtDepartment` INT NOT NULL AUTO_INCREMENT ,
  3. `DepartmentCode` VARCHAR(10) NULL ,
  4. `DepartmentName` VARCHAR(45) NULL ,
  5. `DepartmentSupervisor` VARCHAR(45) NULL ,
  6. `tStatus_idtStatus` INT NOT NULL ,
  7. PRIMARY KEY (`idtDepartment`) ,
  8. INDEX `fk_tDepartment_tStatus` (`tStatus_idtStatus` ASC) ,
  9. CONSTRAINT `fk_tDepartment_tStatus`
  10. FOREIGN KEY (`tStatus_idtStatus` )
  11. REFERENCES `timeDB`.`tStatus` (`idtStatus` )
  12. ON DELETE NO ACTION
  13. ON UPDATE CASCADE)
  14. ENGINE = InnoDB
To copy to clipboard, switch view to plain text mode 

tStatus:
(contains fk for statusid (i.e. active/inactive))
Qt Code:
  1. CREATE TABLE IF NOT EXISTS `timeDB`.`tStatus` (
  2. `idtStatus` INT NOT NULL AUTO_INCREMENT ,
  3. `StatusDescription` VARCHAR(45) NOT NULL ,
  4. PRIMARY KEY (`idtStatus`) )
  5. ENGINE = InnoDB
To copy to clipboard, switch view to plain text mode 

tEmployee - Data:
Qt Code:
  1. 1 QQ QQ QQ 1 1 2010-05-05 00:00:00
  2. 2 qq qw ww 1 1 2010-05-05 00:00:00
  3. 17 test 2 1 2010-08-03 00:00:00
  4. 18 asdgd asd asd 1 1 2010-07-30 00:00:00
  5. 19 QQ QQ QQ 1 1 2010-05-05 00:00:00
  6. 20 QQ QQ QQ 1 1 2010-05-05 00:00:00
To copy to clipboard, switch view to plain text mode 
tDepartment - Data:
Qt Code:
  1. 1 t t1 T 1
  2. 2 R R2 R 1
To copy to clipboard, switch view to plain text mode 

tStatus - Data:
Qt Code:
  1. 1 Active
  2. 2 InActive
To copy to clipboard, switch view to plain text mode 

ok, so now when I add an employee to the table, I basically implement the following: