Qt creator header files - qt-creator

I recently switched from Visual Studios 2013 on Windows to Qt Creator on Ubuntu. Where can I find the header files for algorithm.h and math.h?
In Visual Studios I can simply just go to the Solutions Explorer and look at the dependencies.

You can place the cursor on math.h in #include <math.h> then press F2.
STL headers (like algorithm) have no extension in normal systems (i.e. non-MSVC), so #include <algorithm> instead of algorithm.h.

Related

Create CMake Qt project in Visual Studio 2017

So basically I want to write a GUI application using Qt framework. I also need to make it possible to work on this project under Linux, so I thought about CMake, which would automate a lot of things for me.
My main editor on Windows is Visual Studio 2017, so I've installed Qt VS plugin, so when I want to create a new project I have 2 options to choose: new CMake project or new Qt GUI application project. This confuses me a little bit, cuz I know that Qt enforces qmake by default.
So my question is: How do I create Qt GUI application project in Visual Studio, which would use CMake as a build system? (so do I choose CMake and add Qt to it, or do I choose Qt GUI application and then somehow add CMake to it?)
The minimal setup you need if you want to see a window is following:
CMakeLists.txt
cmake_minimum_required(VERSION 3.1)
set(CMAKE_CXX_STANDARD 11)
find_package(Qt5Widgets)
add_executable(window main.cpp)
target_link_libraries(window Qt5::Widgets)
main.cpp
#include <QApplication>
#include <QWidget>
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
QWidget window;
window.show();
return app.exec();
}
It is not tied to windows or linux and should run almost everywhere.
But then you will most probably need more Qt feature. So the logical steps would be to enable AUTOMOC and enable CMAKE_INCLUDE_CURRENT_DIR as the manual referenced by Amit Singh says.

How to remove windows.h calls from application?

I have an application that uses windows.h but I am tasked with removing the calls to Windows functions.
I am using Visual Studio Express 2010 and when I delete the #include "windows.h" line the code is still able to compile and I can right click and "Go To Definition" for all the variables associate with the windows include file.
I removed $(WindowsSdkDir)include; from the VC++ Directories in the Configuration Properties page but that didn't seem to make a difference. I believed that could be the case because windows.h can be found at C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\windows.h on my computer.
How do I completely break this link so Visual Studio can give me errors for all calls to that library?
Use the /showIncludes command switch to search for indirect includes of windows.h
http://msdn.microsoft.com/en-us/library/hdkef6tk.aspx

fstream.h and iostream.h with VS2010

Code that worked great in older versions of Visual Studio no longer compile. For example:
#include <fstream.h>
#include <iostream.h>
no longer compile. I'm trying to read in a binary data file using VC++ and VS2010. Why do such basic tools no longer work?
Don
In C++ (at least according to modern standards), you don't have to write the extensions of the standard header files:
#include <fstream>
#include <iostream>
Some compilers will just generate warnings when you write the extension, but I guess new versions of Visual treat it as an error.

Include QT file problem in Visual Studio 2008

When I type
#include <QObject>
it complains that it couldn't find file.
but if I type
#include <QtCore\QObject>
It works properly.
I moved VS2005 to VS2008, this was not the case in VS2005, and it started with VS2008. Why am I getting this error?
Actually it's not so big problem. You need to check you include directories and add (path_to_qt_headers)/QtCore, (path_to_qt_headers)/QtGui and directories for other modules you are using. According to your problem description you have added only (path_to_qt_headers) itself.
If Qt set up correctly both #include <QObject> and #include <QtCore/QObject> should work but second one works in more cases. I remember I saw some notice somewhere in the Qt documentation that it might be better to using second include style. At the same time this long include version is recommended in the KDE coding guidelines.
For myself I preffere to follow #include <QtModule/QClass> include convention
Maybe installing the Visual Studio addin for Qt would solve the problem (besides providing advanced debug and Qt project management tools).

Quickly determine if code is Visual C++ or not

Is there a quick way to determine whether a Visual Studio C++ project is written in plain C++ or Visual C++?
If any files include the lines #pragma once or #include "stdafx.h", it's very likely Visual C++.
(Are there any other compilers that implement #pragma once?)
No -- Visual C++ will compile most plain C++ without any problems. If you want to check for use of Windows-specific "stuff", checking for inclusion (directly or indirectly) of <windows.h> would probably be a reasonable start.
If is Visual C++ it usually has a project.sln or project.vcproj file in the project directory.

Resources