Does the qmake -project work?
-
I have a quite large Makefile project (console) that compiles within MSYS2.
I imported it into QtCreator and managed to compile it with mingw32 5.3.0.Because now I want to extend it with some Qt features I run the following in the root of the repository:
qmake -project -nopwd path/to/the/Makefile
It created a *.pro file, but opening it as a project doesn't compile anymore!
Here the documentation:http://doc.qt.io/qt-5.8/qmake-running.html#project-mode-options
I was thinking it should handle the existing Makefile correctly, in order to continue the development using qmake. Am I wrong?
-
Hi,
I may be wrong but I don't think that qmake parses the Makefile in order create the .pro file.
From a first step, I'd just run
qmake -project
in the root of your project. -
Hi,
I may be wrong but I don't think that qmake parses the Makefile in order create the .pro file.
From a first step, I'd just run
qmake -project
in the root of your project.@SGaist said in Does the qmake -project work?:
From a first step, I'd just run
qmake -project
in the root of your project.Done! It just added all sources and headers files found in each subfolder.
Perhaps this is not the best approach.My goal is to use Qt features (Q_OBJECT, signals, slots...) in the main.c:
https://github.com/bluekitchen/btstack/blob/develop/port/windows-winusb/main.c
What's the right way to do this?
-
@SGaist said in Does the qmake -project work?:
From a first step, I'd just run
qmake -project
in the root of your project.Done! It just added all sources and headers files found in each subfolder.
Perhaps this is not the best approach.My goal is to use Qt features (Q_OBJECT, signals, slots...) in the main.c:
https://github.com/bluekitchen/btstack/blob/develop/port/windows-winusb/main.c
What's the right way to do this?
@Mark81 Well, use Qt features. Read Qt documentation, take a look at examples.
http://doc.qt.io/qt-5/qtexamplesandtutorials.html
http://doc.qt.io/qt-5.8/signalsandslots.html
https://wiki.qt.io/Qt_for_BeginnersYou cannot do it just in main.c, Qt is a C++ framework - you will need to write C++ code, C++ classes, ...
-
@SGaist said in Does the qmake -project work?:
From a first step, I'd just run
qmake -project
in the root of your project.Done! It just added all sources and headers files found in each subfolder.
Perhaps this is not the best approach.My goal is to use Qt features (Q_OBJECT, signals, slots...) in the main.c:
https://github.com/bluekitchen/btstack/blob/develop/port/windows-winusb/main.c
What's the right way to do this?
-
@Mark81 Well, use Qt features. Read Qt documentation, take a look at examples.
http://doc.qt.io/qt-5/qtexamplesandtutorials.html
http://doc.qt.io/qt-5.8/signalsandslots.html
https://wiki.qt.io/Qt_for_BeginnersYou cannot do it just in main.c, Qt is a C++ framework - you will need to write C++ code, C++ classes, ...
@jsulm Thanks for the links. I'm not new to Qt... I'm not an expert developer but I use this framework since Qt3. My question is exactly how to "migrate" from an existing Makefile C project to a Qt one.
Of course I need to write C++ code and classes. It's exactly what I want! But I need to maintain the functionality of the underlying C project - i.e. calling its functions inside slots.
-
@J.Hilk said in Does the qmake -project work?:
@Mark81 to add to @jsulm , you can force the issue, using connect in main.cpp, if you really want/have to with this:
e.g:
QPushButton *btnExit = new QPushButton(); QObject::connect(btnExit,SIGNAL(clicked()),qApp,SLOT(quit()));
I understand it, but as @jsulm said, this is a C project, while I'm trying to embed into a C++ one.
A different approach would be creating a new Qt console project and add all the repository files, but the main.c - replaced from my main.cpp. I'm asking help how to do this.
-
@J.Hilk said in Does the qmake -project work?:
@Mark81 to add to @jsulm , you can force the issue, using connect in main.cpp, if you really want/have to with this:
e.g:
QPushButton *btnExit = new QPushButton(); QObject::connect(btnExit,SIGNAL(clicked()),qApp,SLOT(quit()));
I understand it, but as @jsulm said, this is a C project, while I'm trying to embed into a C++ one.
A different approach would be creating a new Qt console project and add all the repository files, but the main.c - replaced from my main.cpp. I'm asking help how to do this.
-
You seem to have your own event loop.
What exactly is that application supposed to do ?
-
@SGaist said in Does the qmake -project work?:
What exactly is that application supposed to do ?
Sorry, are you talking about my application or the existing one?
The latter, the github one, is a Bluetooth stack. The actual main loop is just an example to be extended for own applications. For this reason I would embed that code into my Qt project.
-
Then one way is to create a wrapper object that handles what your main.c does. Then it will make things easier to integrate with your application.
Does your stack have its own event loop ?
-
Then one way is to create a wrapper object that handles what your main.c does. Then it will make things easier to integrate with your application.
Does your stack have its own event loop ?
@SGaist said in Does the qmake -project work?:
Then one way is to create a wrapper object that handles what your main.c does. Then it will make things easier to integrate with your application.
Is there somewhere a minimal example how to do this? I'm afraid how to handle both C and C++ code in the same project.
Does your stack have its own event loop ?
Yes:
-
Well, using Qt you're already doing that. A great part of Qt is dealing with lower-level C interfaces.
As for API design, this old Qt Quarterly article is pretty good.