Are your lenses M42 or K-mount?
If k-mount they will work just fine without an adapter. However, you will need to meter manually by selecting the aperture on the lens and then pressing the green button (assuming it is not mapped to something else) and then taking the picture. The lenses will only work in M mode. On the k-x I believe the +/- button can also be used to manually meter.
There is a menu setting that needs to be turned on, I don't have my k-x handy but it is something like "Use aperture ring". This needs to be on, the default is off.
Also, read this section, it will help:
https://www.pentaxforums.com/forums/pentax-beginners-corner-q/110658-using-ma...x-dslrs-f.html