I usually setup 3 liability accounts and one expense account:
23x1 401k Liability EE
23x2 401k Liability ER
23x3 401k Liability Loan EE
63x0 401k Expense ER
Assuming you are already accruing labor expense for payroll liability, in addition to that,
(similar to accruing payroll taxes ER).
Accrue expense each payperiod:
DR 63xx
CR 23x2
Then clear all liabilities when paid:
DR 23xx
CR 1000 Cash
401k Loan amortization is done by 401k Admin. You just need to record payments made that are deducted from paychecks. I don't use QB payroll so can't help much on the mechanics, but this is accounting to do.