Qt Designer code generation issue - c++

I am using Qt Designer. When I lauch the code generation (View code), I have the following issue:
Code Generation Failed
Unable to launch C:/Python27/Lib/site-packages/PyQt4\uic.
I tried to use the tips here
You can generate code by using the pyuic4.bat file
located under the PyQt4 install directory, on Win usually
C:/Python##/Lib/site-packages/PyQt4.
Usage from the command line is:
pyuic4.bat inputfile.ui > output.py
pyuic4.bat inputfile.ui > output.py gives me an output.py file, but launching this output.py script gives nothing. The execution is pending for a while, then stop. I don't know if code has been generated / where it should have been generated ... What I would like is the code in C++/Qt. What should I do once I have output.py ?
Could somebody explain more precisely how to proceed ? Is this tip making possible to see the rendering of the UI, or the generated code (which I want) ? Where can I find the code ? What is another working trick ?

You can do this way to generate C++ file
cmd
uic -o sample.h sample.ui
with sample.ui the .ui file first saved with Qt Designer. Code is generated in sample.h

Related

Error [outdebug does not exist] In Debugging basic C++ in visual Studio code

I am new to programming. I am using ubuntu and .deb for installing vs code.
When I try to debug a program(hello world in my case) it gives me error, that launch: program '/home/(myusername)/Projects/helloworld/build/Debug/outDebug' does not exist.
My Temporary Workaround.
I go to launch.json file, in program field, i paste location for a compiled executable file.
Finally, I am looking for a permanent fix to my issue.
After a lot of stuff, I learned that using "${workspaceFolder}/compiledfilename" in program field is the best and shortest way. You manually lead to the like home/user/desktop/project/main but that can is long and small stuff can cause errors.
launch.json file pic
Note: program is typically 4th entry under configuration in launch.json file.
In the configuration section, write "workSpaceFolder/compiledFileName" in program section.

How to set up C++ Testmate in VS Code

Ok, n00b question. I have a cpp file. I can build and run it in the terminal. I can build and run it using clang++ in VSCode.
Then I add gtest to it. I can compile in the terminal with g++ -std=c++0x $FILENAME -lgtest -lgtest_main -pthread and then run, and the tests work.
I install the C++ TestMate extension in VSCode. Everything I see on the internet implies it should just work. But my test explorer is empty and I don't see any test indicators in the code window.
I've obviously missed something extremely basic. Please help!
Executables should be placed inside the out or build folder of your workspace. Or one can modify the testMate.cpp.test.executables config.
I'd say, never assume something will "just work".
You'll still have to read the manual and figure out what are the names of config properties. I won't provide exact examples, because even though I've only used this extension for a short time, its name, and therefore full properties path, has already changed, so any example might get obsolete quite fast.
The general idea is: this extension monitors some files/folders, when they change, it assumes those are executables created using either gtest or catch2. The extension tries to run them with standard (for those frameworks) flags to obtain a list of test suites and test cases. If it succeeds, it will parse the output and create a nice list in the side panel. Markers in the code are also dependent on the exactly same parsed output, so if you have one, you have the other as well.
From the above, you need 3 things to make this work:
Provide correct path (or a glob pattern) for finding all test executables (while ignoring all non-test executables) in the extension config. There are different ways to do this, depending on the complexity of your setup, they are all in the documentation though.
Do not modify the output of the test executable. For example, if you happen to print something to stdout/stderr before gtest implementation parses and processes its standard flags, extension will fail to parse the output of ./your_test_binary --gtest-list_tests.
If your test executable needs additional setup to run correctly (env vars, cwd), make sure, that you use the "advanced" configuration for the extension and you configure those properties accordingly.
To troubleshoot #2 and #3 you can turn on debug logging for the extension (again, in the VSCode's config json), this will cause an additional "Output" tab/category to be created, where you can see, which files were considered, which were run, what was the output, and what caused this exact file to be ignored.
This messed with me for a while, I did as Mate059 answered above and it didn't work.
Later on I found out that the reason it didn't work was because I was using a Linux terminal inside windows (enabled from the features section) and I previously had installed the G++ compiler using the linux terminal so the compiler was turning my code into a .out file, for some reason TestMate could not read .out files.
Once I compiled the C++ source file using the powershell terminal it created a .exe file which I then changed the path in the setting.json as Mate059 said and it showed up.
TL;DR
Mate059 gave a great answer, go into settings.json inside your .vscode folder and modify "testMate.cpp.test.executables": "filename.exe".
For me it also worked using the wildcard * instead of filename.exe but I do not suggest to do that as in that might mess up something with the .exe from the main cpp file and what not.

PyQt: Running pyuic.py without command line

I am unable to use the command prompt due to security restrictions on my work PC and I am trying unsuccessfully to find a way to convert .ui files to .py without the pyuic4 batch file.
I have found the uic/pyuic.py program but have been unsuccessful in my attempts to run it from a python console.
Any help with this would be great.
Cheers.
Thanks ekhumoro,
Was able to implement the uic successfully, using compileUiDir, since I have multiple .ui files. Final code was:
from PyQt4 import uic
folderToConvert = r'filePathGoesHere'
uic.compileUiDir(folderToConvert,recurse=False)
This is a .py file that I run or call/execute prior to running the main program. Very handy!

Can I instrument an exe file using vsinstr?

I've been trying to verify the code coverage of an exe file. To achieve this, I'm trying to instrument the exe file (not dll) and then start/stop the coverage.
Every tutorial describes about the instrumentation of dll only. Is it possible to achieve it for exe? If yes, what are the special options I need to give.
Here are the commands, I've been trying for exe:
vsinstr -coverage Test.exe
Returns success message and creates another copy of exe
vsperfcmd -start:coverage -output:Result.coverage
vsperfcmd -shutdown
It creates the output file successfully. But when the file opened in visual studio shows the error message:
"Empty results generated: No binaries were instrumented. Make sure the tests ran, required binaries were loaded, had matching symbol files, and were not excluded through custom settings."
Please help
Your first command starts the profiler service and your second one shuts it down (and causes it to write its output). What you're missing is the -attach command.
vsperfcmd -attach:PID
where PID is your process's numerical ID.
Once you're attached to a process, it will start collecting coverage data. Do whatever you need to exercise your code, then run the shutdown command to get your output.

Trouble getting a Qt Reference Document program to work(Minehunt)... its just blank when run... no errors though?

http://docs.huihoo.com/qt/4.7/demos-declarative-minehunt.html
When I build and run... I just get a blank white rectangle... game is MineHunt.
The source code is in the URL. I created files and copied and pasted into Qt Creator 4.7.
Running in Linux.
No need to downvote. Deploying qml apps does not seem to be easy for beginners. jdl, I don't know if I can help you. Currently I am only on Linux. But what I did:
I copied the whole folder minehunt in my destination folder (/tmp/mine). When I ran qmake I got:
WARNING: Include file
/tmp/mine/helper/qmlapplicationviewer/qmlapplicationviewer.pri not
found
So I also copied the examples/declarative/helper folder into /tmp/mine.
Looked like this:
/tmp
/mine
/minehunt
/helper
Then I changed into minhunt, did 'qmake' and 'make'. A few seconds later I had a working minehunt binary in /tmp/mine/minehunt/.
I'll try tomorrow the Windows build.
Edit: Ok, tried now under Windows 7. Qt4.
QtCreator opened.
Project ...qt\demos\declarative\minehunt\minehunt.pro
loaded. Normally in release mode compiled. No problem. A file minehunt.exe was created in ....qt\demos\declarative\minehunt\release. Started: White screen. Exactly as you described it. In ...qt\demos\declarative\minehunt I found a folder 'qml'. I moved this folder and the minehunt.exe into another folder (myMineFolder). Simulating a simple deployment this way. Clicked on minehunt.exe -> worked like a charm.
So my folder layout:
myMineFolder
qml
minehunt.exe
But of course, I have set my PATH variable correctly to my Qt installation.