Creating/writing into a new file in Qt

前端 未结 6 1611
陌清茗
陌清茗 2021-01-31 14:31

I am trying to write into a file and if the file doesn\'t exist create it. I have searched on the internet and nothing worked for me.

My code looks currently like this:<

6条回答
  •  借酒劲吻你
    2021-01-31 14:46

    Are you sure you're in the right directory?
    Opening a file without a full path will open it in the current working directory. In most cases this is not what you want. Try changing the first line to

    QString filename="c:\\Data.txt" or
    QString filename="c:/Data.txt"

    and see if the file is created in c:\

提交回复
热议问题