Qt: Different tableWidget member names on workstations - qt

I am using Qt on two ubuntu machines and am copying the source code from time to time between them. I found a really annoying problem when doing that and I can't figure out why this happens.I am using a table Widget to display some data and want to stretch the horizontal header to fit the content length. To do that I use the following line:
ui->tableWidget->horizontalHeader()->setResizeMode(0, QHeaderView::ResizeToContents);
This works just fine.
I have a few of this codelines.
However, when I now copy over my source code to the other PC to work on it, I get the following compile error:
'class QHeaderView' has no member named 'setResizeMode'
Renaming 'setResizeMode' to 'setSectionResizeMode' will work just fine to fix that problem, but if I now copy the source code back to the first PC, it tells me:
'class QHeaderView' has no member named 'setSectionResizeMode'
...and I have to rename it to 'setResizeMode' again, to continue working.
I checked the Qt version on both PCs and they are both "Qt Creator 2.7.0" based on "Qt 5.0.1 (32 bit)".
Also the systems are up to date.
The only difference is, that I am using one of them in english system language, the other one in german...but I don't see how that would affect Qt's member declaration. o.O
Anyone knows what the problem is?
The constant renaming can get annoying over time.

it may be that the QT header versions don't match up
double check the QT_VERSION_STR in QtCore/qglobal.h
for a quick check if you are too lazy add a #pragma message("QT version: " QT_VERSION_STR) to the code to have the compiler output it while compiling

Related

Qt VS Tools Generating Incorrect MOC Command

I've been struggling all afternoon to track down an issue with the Qt VS Tools in Visual Studio 2013. I'm trying to update an existing .vcxproj file that used a home-grown mechanism for generating MOC, UIC, etc. files to use the Qt VS Tools mechanism instead.
The problem I'm having is in the MOC command that's getting generated for .h files that include the Q_OBJECT macro. A sample line (reduced for brevity) is here:
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" "-I$(QTDIR)\include\QtGui" "-I$(NOINHERIT)"</Command>
The problem is that NOINHERIT doesn't exist, so the "-I$(NOINHERIT)" gets evaluated to "-I" without a value, and the MOC compiler complains and doesn't generate the MOC file. I've tried cleaning up inherited paths, checking and unchecking the "Inherit from parent or project defaults", and the only change I sometimes see is that it has "-I" without the NOINHERIT macro.
Completely starting over with a new .vcxproj file is beginning to feel like my only hope, but that's a much larger task than I'd like to take since there's a significant number of them with interdependencies that I'd rather not create again.
I'm using the latest Qt VS Tools, which is version 2.3.2. Any ideas on how to resolve this?
Naturally, five minutes after I post, I found the issue. An included property file had this:
<AdditionalIncludeDirectories></AdditionalIncludeDirectories>
Rather than this, which solved the problem:
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
Interestingly, and for what it's worth, this did not work:
<AdditionalIncludeDirectories />
Add the %(AdditionalIncludeDirectories) at project->C/C++ -> General -> Additional Include Directories.
%(AdditionalIncludeDirectories) is added by default, but if for some reason, this is overwrite by mistake, then we will get an error as such.
Moc'ing XXXXXXX.h...
Missing value after '-I'.

Qt Creator - Not Getting Function Argument Hints For Some OpenCV Constructors

I'm working with OpenCV in Qt Creator and everything is running fine. There is just this one problem that I don;t get function argument hints for some OpenCV constructors like cv::Size() and cv::Point(). I do however get argument hints for all functions of OpenCV. is there something that can be done about this? I do get argument hints for these in Visual Studio though.
In some versions of QtCreator the autocompletion does not work with typedef type objects. This bug was reported time ago, but I am not sure that it has been fixed (at least, it doesn't work for me in v3.1.0). Point, Size and Rect are examples of typedef variables (they are typedefs from Point_<int>, Size_<int> and Rect_<int> respectively) with which autocompletion does not work.
If at anytime you forget the constructor parameters, what I do is writing any of the template names (Point_, Rect_ or Size_) and QtCreator will autocomplete :)

Inheriting forms in Qt with CMake (multiple inheritance method)

I imagine this is fairly straight-forward, but I admit I'm not well-versed in CMake (or Qt for that matter), so here's the problem:
I have a form that was built in Qt Designer (with a .ui file). Two classes have been created that are based on this form. Both classes have a lot of duplicated code. So, I wanted to create a base class that inherited the formname.ui file using the multiple inheritance method to manage that common code.
The problem is that I don't know how to get CMake to build it correctly. Compiling gives me the error ui_formname.h: No such file or directory.
I've identified the following elements as necessary to get CMake to buld this correctly:
set (UI_HDR ${CMAKE_SOURCE_DIR}/path/to/formname.ui)
QT4_WRAP_UI (COMPONENT_UI_HDR ${UI_HDR})
include_directories(${CMAKE_CURRENT_BINARY_DIR}) #Necessary here?
The difference between this and the other two cases is that this cmakefile is not building an executable, whereas in the other two cases, it was. It may be I'm missing something else, but the lack of an add_executable line is the most obvious difference that I can see, as the COMPONENT_UI_HDR variable would be included in that list, were it there.
Any suggestions on how to work around that?
Solved the problem. Indeed, I was right about the "add_executable" difference. Since this was a library and not an executable, I had to add a reference to the wrapped variable in the add_library call, i.e.:
add_library ( ${...} ${COMPONENT_UI_HDR} )
Compiled without a hitch...

GNAT Programming Suite: Cross-Reference Info Not Up To Date (this is a guess)

I'm trying to get package references resolved during a build, using GNAT Programming Suite (hosted on Win XP). In the Builder Results, I get errors like this one:
file "ac_configuration_s.ada" not found
Clicking on the error takes me to a line like this:
with
Ac_Configuration,
Dispense_Timer,
...
The first item (Ac_Configuration) isn't resolved, but the second item (Dispense_Time) is resolved. I have several others that do or don't resolve. All of the files in question (spec and body) are identified as source files.
When I hover my mouse over the line with the error, a popup shows up that offers this:
(Cross-references info not up to date. This is a guess.)
Ac_Configuration
local package declared at D_Ac_Config_S.Ada:85
The guess is correct, but I don't know how to use this. How do I get this to correctly build?
Update
Here is teh call to gcc
gcc -c "-gnatec=C:\Source\build\GNAT-TEMP-000001.TMP" -I- -gnatA
-x ada "-gnatem=C:\Source\build\GNAT-TEMP-000002.TMP" "C:\Source\C_Cbt_Main_B.Ada"
I don't see a reference to teh "miimal" switch.
In this case, there is no corresponding body file file D_Ac_Config_S.Ada. So the is no body file to compile separately.
When I right click on the package reference inside the with, I can goto the declaration of Ac_Configuration and every other package name that is the source of an error. So these lreferences are being resolved somehow.
By the way, I have not used ADA before, so I'm still trying to understand everything.
It looks as though you're using _s.ada as the suffix for specs, and I'm guessing _b.ada for bodies?
GNAT may have difficulty with this naming convention. It's possible, using a GNAT Project file (.gpr), to alter GNAT's default convention ({unit-name}.ads for specs, {unit-name}.adb for bodies) but the rules (see "Spec_Suffix") say "It cannot start with an underscore followed by an alphanumeric character" (I haven't tried this, but you can see that it would confuse the issue if you had a package Foo_S, for example).
LATER: It turns out that GNAT (GPL, 4.7, 4.8) is quite happy with your suffixes!
If the package Ac_Configuration is really a local package declared at line 85 of D_Ac_Config_S.Ada, then there's your problem; you can only with a library unit, which in this case would be D_Ac_Config.
with D_Ac_Config;
...
package Foo is
...
Bar : D_Ac_Config.Ac_Configuration.Baz;
I wonder whether D_Ac_Config_S.Ada (for example) actually contains multiple Ada units? (if so, compiling that file should result in a compilation error such as end of file expected, file can have only one compilation unit). GNAT doesn't support this at compile time, providing instead a utility gnatchop.
Would it be possible to just gnatchop all the source and be done with it?
Hm, I think it sounds like the compiler's got a bad set of objects/ALIs it's working with, hence the cross-reference not up to date error. (Usually the compiler's good about keeping things up to date; but you may want to check to see if the "minimal recompilation" switch is set for the project.)
Have you tried compiling just the ["owning"] file D_Ac_Config_S.Ada? (i.e. if it were a spec, go to the corresponding body and compile that.) That should force its ALI/object files to be updated.
Then try building as normal.
-- PS: you might have to clean first.

How does one compile single file Xcode 4?

While I used to compile a single source file with Cmd+K in prior versions of Xcode, how does one do the same in Xcode 4? (Note that this is different than preprocessing or showing the disassembly of the file.) If compiling from a command line is proposed then it must be such that the project's settings, include paths, preprocessor definitions, etc., are all included.
An example use case is where I make a header file change but only want to test the change's effect with respect to a single source file, not all of the files that depend upon that header.
The command has been moved to the Perform Action submenu. Look under
Product > Perform Action > Compile filename.cpp
To assign Cmd+K to it, go to
File > Preferences > Key Bindings > Product Menu group
and you'll find Compile File where you can assign a key. Cmd+K is assigned to Clear Console now by default, so be sure to remove that binding to avoid conflicts.
One way that I have found to do this is to using the following menu commands:
Product -> Generate Output -> Generate Preprocessed File
Product -> Generate Output -> Generate Assembly File
This may not be exactly what you want, but it will compile the single file.
When you build a project, xcode runs compilation command. You can check the log, search for your file and copy paste that command on Terminal. It'll compile only the file for which you copy/pasted on the terminal.
If your file is C (or C++) file, then simply open your terminal, go to the folder in which the file resides and type
gcc -o outputFile inputFile.c
I am not familar with Objective-c that much, but GCC might work since it's only a superset of C, just like C++.
Hope that was helpful :)
The keyboard shortcut Cmd+K on Xcode 3 and before has been remapped to Cmd+B on Xcode 4
Along the same lines, Cmd+Return was remapped to Cmd+R (in case you ever used that)
The common requirement for single file compilation is checking it for syntax errors. (atleast for me). Since xcode4 highlights syntax errors as you type. It seems apple removed that feature.

Resources