How to restart Linux from inside a C++ program?

后端 未结 7 1966
天涯浪人
天涯浪人 2021-02-07 08:59

I have a Qt 4 GUI where I need to have a option in a drop-down menu that allows the user to choose to restart the computer. I realize this might seem redunant with the ability t

7条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-07 09:31

    Have you tried running a shell script, using gksudo? Something like

    gksudo shutdown -r
    

    With any luck, that should pull up a modal dialogue to get user credentials.

提交回复
热议问题