We develop a new heavy quark transport model, QLBT, to simulate the dynamical propagation of heavy quarks inside the quark-gluon plasma (QGP) created in relativistic heavy-ion collisions. Our QLBT model is based on the linear Boltzmann transport (LBT) model with the ideal QGP replaced by a collection of quasi-particles to account for the non-perturbative interactions among quarks and gluons of the hot QGP. The thermal masses of quasi-particles are fitted to the equation of state from lattice QCD simulations using the Bayesian statistical analysis method. Combining QLBT with our advanced hybrid fragmentation-coalescence hadronization approach, we calculate the nuclear modification factor \[R_\mathrm {AA}\] and the elliptic flow \[v_2\] of D mesons at the Relativistic Heavy-Ion Collider and the Large Hadron Collider. By comparing our QLBT calculation to the experimental data on the D meson \[R_\mathrm {AA}\] and \[v_2\] , we extract the heavy quark transport parameter \[\hat{q}\] and diffusion coefficient \[D_\mathrm {s}\] in the temperature range of \[1-4~T_\mathrm {c}\] , and compare them with the lattice QCD results and other phenomenological studies.