Qt Creator problem. UI changes not showing when pr

2020-06-19 03:09发布

I'm making changes to a form in Creator but when I build the changes are not being "refreshed". I've gone so far as to remove every element from the form and get rid of every stylesheet but when I build the project I get the same result; as if I had never made a change at all. What gives? Am I missing something obvious? (obvious to everyone but me.. obviously)

8条回答
Anthone
2楼-- · 2020-06-19 03:30

Most likely cause if that your make procedure is not noticing the changes in the .ui file, and so it is not calling the uic tool. Try to do a make clean to see if it helps, and check your build log to see if uic is being called.

查看更多
淡お忘
3楼-- · 2020-06-19 03:30

I stumbled upon this issue as well and one thing I noticed was that my program was still running in the background without me knowing. Ending the task through task manager fixes it and you can make changes again.

查看更多
Explosion°爆炸
4楼-- · 2020-06-19 03:31

Problem is indeed stale generated files in project source directory. This can happen both with genrated ui_*.h files, as well as with moc_*.* files. Below is not covered by existing answers, so here we go:

To remove generated files from the project source directory, without affecting Qt Creator settings or current shadow build directories, there are two principal ways, which can also be combined for extra coverage.

  1. Go to Qt command prompt, go to project source directory and run these commands:

    qmake -r
    make clean
    make distclean
    

    1st one will recursively create makefiles. 2nd one will remove all files produced by building the project. 3rd one will remove the makefiles again. Then continue using shadow build from Qt Creator as before.

    The problem with this is, it will leave files which are not part of the project. So if some files have been removed from project, related generated files may remain, and cause trouble if files with same name are added back. So even after this it is good idea to verify no ui_* or moc_* files remain, if you know you have removed files from project.

  2. Use your version control software to first commit or stash/shelve all uncommitted changes, and then remove all unversioned (also otherwise ignored) files. For some version control software this may not be easy as git clean -dxf (beware, that will also lose uncommited changes and Qt Creator's custom project settings), and in that case it may be easier to just remove project source directory and get a clean checkout.

    The problem with this is, if some generated files have accidentally been added to project, they will not be cleaned up with this. So it may still be a good idea to do the step 1 above too.

Above steps should be in sync so that after step 1, any files in source directory (except Qt Creators's projectname.pro.user and possible *~ backup files) should be under in version control.

查看更多
贼婆χ
5楼-- · 2020-06-19 03:38

I have this problem and i solve it by changing the project path. I had stored the project in my flash memory when i had this problem, then i copy the project folder and it's build folder also in the Desktop and open it with QtCreator and the problem was solved.

查看更多
我想做一个坏孩纸
6楼-- · 2020-06-19 03:43

For me, the solution was to change the BuildDirectory to the same directory where the code is, instead of the **-build-desktop directory.

查看更多
Emotional °昔
7楼-- · 2020-06-19 03:43

A few suggestions:

  • Perform a make distclean.
  • Use a shadow build directory. Building “inside” the source code is not advised.
  • Check your computer’s clock and the date and time of your files.
查看更多
登录 后发表回答