Just wanna know if I can ask users for root password/user password of the computer in a QDialog GUI?
You can ask the user to provide anything you want. This has precisely nothing to do with what your code does with the provided information.

There is no auto-magic, obtain root login credentials, change the process effective uid to zero, and do stuff dialog. You have to code everything you want done with the user's input.