qt gui project in eclipse using qt plugin - c++

So I have made a new qt gui project, gave it a name and right after it was created i received this error:
"No default QT version is set.Open the QT page in the preferences dialogue and add a QT version."
I open the preferences dialog,click add ,but when i have to give the path for the bin and the include files,i can't find any where my QT SDK is installed.
I installed qt sdk 1.2.1,and qt eclipse integration 1.6.1.
Where are those paths installed in qt sdk?

You are asked to add a Qt version. To do so, go to the eclipse preferences, switch to the Qt page and click on "Add...".
You will then be asked the binary path (of the Qt binary files for the build process, these are for example qmake, moc, ...) and include path (where the Qt header files are stored).
Browse for your Qt installation path and select the subdirectories bin and include respectively.
If you don't know where Qt has been installed to, try to launch the Qt command line (not the Windows default command line) from your Windows start menu and type:
qmake -v
The output should then look similar to this:
QMake version ...
Using Qt version ... in C:\Qt\...\lib
Your bin path sould then be at C:\Qt\...\bin; the include path at C:\Qt\...\include.
Then accept the assistant dialog and select this version as the default version by clicking on the "Default" button. Then retry to build your project.

Related

Install plugin to the stand alone Qt Designer (not Qt creator) using Cmake

I'm new to the Qt designer and I need to make a project which includes a speedometer, luckily I was able to find a plugin on the internet for a speedometer but the problem is I don't know how to install it to the Qt designer and to be added to my widget. I tried to search on the internet and all I found is how to install plugins in Qt creator. Please note that I use the combination of Qt designer, Cmake and visual studio 2010 (not Qt visual studio Addin) to build my project.
Here is the link for the plugin I want to install: https://github.com/efesler/Qt-Speedometer-Widget
In ubuntu, do something like, download:
git clone https://github.com/efesler/Qt-Speedometer-Widget.git
then, you go into your downloaded folder and run qmake Speedometer.pro, then make and finally sudo make install and it is automatically added to Designer as a widget to be used in your form. However, in windows, I have no idea on how to make it appear as a widget in the designer. In any case, you can just add the code to your own project and compile it in your cmake and not with the provided .pro file. If you do so, you can use the Promote widget... option to add a generic widget to your form and make it be the speedometer that you downloaded.

QT File menu not integrating into title bar

I am writing a basic gui application in QT creator 3.5.1 and I am using QT 5.5. I have downloaded QT/QT creator via their website. I am currently running Ubuntu 15.04 64 bit.
I am running into an issue regarding the integration of the menu bar into the title bar. The issue being that no integration is happening (the menu bar isn't appearing in the title bar) . The menu bar appears where it would have in the past, below the tile bar. Here is an image of what is happening:
How can I go about resolving this issue?
UPDATE:
I installed qt 5.4.1 via apt-get, and qt creator. When I compile against this, my title bar integration works! So the question is, what is different? The people I am developing with are using QT 5.5.1, and I would like to use the same version as them. Is there something I can do differently this time around?
The unique way that i found was in this blog. He claims that this method works on Qt Creator, but i've tested on Ubuntu 32/64 bits Qt5 apps (developed by me) and it seems to works fine too!
The steps are:
Open terminal
Enter sudo apt-get install libgtk2.0-dev libdbusmenu-qt5-dev
Set current directory with CD command (the appmenu project will live here)
Enter command apt-get source appmenu-qt5
Now, the blog still using command line but the next steps can be done by opening the project in Qt Creator (the project is on the current directory).
Using some text editor (can be Qt Creator of course), edit the following lines of appmenu/src/src.pro:
CONFIG += X11 link_pkgconfig debug
PKGCONFIG += dbusmenu-qt5 gtk+-2.0
DESTDIR = ./
to (if you want a dynamic library):
CONFIG += X11 link_pkgconfig
PKGCONFIG += dbusmenu-qt5 gtk+-2.0
or (if you want a statically linked library):
CONFIG += X11 link_pkgconfig static
PKGCONFIG += dbusmenu-qt5 gtk+-2.0
Open the project with Qt Creator (if you haven't done already) select the mode of build (Release mode seems to be smaller in size) and build.
If built succesfully (as a dynamic library), you will have inside your Qt5 installation folder /plugins/platformthemes a plugin called libappmenu-qt5.so. To get menu integration, just place the lib in a platformthemes subfolder of your target app (including Qt Creator).
Or if built succesfully (as a statically linked library), you will have inside your Qt5 installation folder /plugins/platformthemes a file libappmenu-qt5.a. This is the static library. To integrate it with your app, add to your project file:
QT += core-private gui-private platformsupport-private dbus widgets
LIBS += $$[QT_INSTALL_DATA]/plugins/platformthemes/libappmenu-qt5.a
CONFIG += X11 link_pkgconfig
PKGCONFIG += dbusmenu-qt5 gtk+-2.0
And to your main.cpp:
#include <QtPlugin>
Q_IMPORT_PLUGIN(AppMenuPlatformThemePlugin)
int main(int argc, char *argv[])
...
And this should be the result:
Edit (valid when building as dynamic library): Note that you wouldn't need to recompile your Qt apps nor Qt Creator .
For Qt Creator you need to place libappmenu-qt5.so in your Qt Installation folder: /Tools/QtCreator/lib/Qt/plugins/platformthemes
If you want to redistribute your Qt application, just share inside the folder of your executable the folder platformthemes with libappmenu-qt5.so inside it. Like any other Qt plugin.
Edit 2: Is also possible to build a statically linked plugin, if you don't want extra dependencies.
You can try to set "nativeMenuBar" property of QMenuBar Object is false.
Because this property has the default value is true.

QtCreator: No valid kits found

Installed just the IDE on Windows 7. I want to create a Plain C++ Project (Non-QT Project); however I get an error: No valid kits found. When I click on Options->Kits, I see the Desktop (default) kit, and it shows no errors.
Am I getting the error because I didn't install a Qt library? If so, is there any way I can bypass downloading/installing that and just use the IDE?
Found the issue. Qt Creator wants you to use a compiler listed under one of their Qt libraries. Use the Maintenance Tool to install this.
To do so:
Go to Tools -> Options.... Select Build & Run on left. Open Kits tab.
You should have Manual -> Desktop (default) line in list. Choose it.
Now select something like Qt 5.5.1 in PATH (qt5) in Qt version
combobox and click Apply button. From now you should be able to
create, build and run empty Qt project.
Though OP is asking about Windows, this error also occurs on Ubuntu Linux and Google lists this result first when you search for the error"QtCreator: No valid kits found".
On Ubuntu this is solved by running:
For Qt5:
sudo apt-get install qt5-default
For Qt4:
sudo apt-get install qt4-dev-tools libqt4-dev libqt4-core libqt4-gui
This question is answered here and here, though those entries are less SEO-friendly...
No valid Kits found
The problem occurs because qt-creator don't know the versions of your qt,
your compiler or your debugger.
First off, let's solve the Qt versions. It may normally solve the others too ;).
You try to create a new project, run select a kit and then there is no kit available in the list.
Follow the steps:
Execute in your terminal the command: sudo apt-get install qt5-default
to install qt version 5.
Verify the version of your Qt and the location of your qmake file. Do this by executing in your terminal the command qmake --version.
You may have a result similar to this line.
QMake version 3.1
Using Qt version 5.9.5 in /usr/lib/x86_64-linux-gnu. What's important here is the location /usr/lib/x86_64-linux-gnu.
Open your Qt-creator.
Go to "Tools>Options" or "Outils>Options"
Select the Qt Versions combobox and select and click "Add" or "Ajouter"
Then find the qmake file in the location of step 2. Here /usr/lib/x86_64-linux-gnu/qt5/bin/ here you have the qmake file for qt5. Open it, click Apply.
Go to "Kits" combobox. Select Desktop(by default) or Desktop(par défaut). Then scroll down to the button to select Qt version: and list down to select the version you just add.
8.Then apply all. Check your compiler and debugger and it's ok. You're done.
Yes I ...
Hope it's help ;)
In my case the issue was that my default kit's Qt version was None.
Go to Tools -> Options... -> Build & Run -> Kits tab, click on the kit you want to make as default and you'll see a list of fields beneath, one of which is Qt version. If it's None, change it to one of the versions available to you in the Qt versions tab which is just next to the Kits tab.
For QT 5.* if you face error at Kits, like No Valid Kits Found, go to Options->Build&Run-> (Kits tab) then you see a Manual category which should list Desktop as the default.
Just go to your OS Terminal and write sudo apt-get install qt5-default, go back to QT Creator and Start your New Project, and there you see the kit option Desktop included in the list.
I had a similar problems after installing Qt in Windows.
This could be because only the Qt creator was installed and not any of the Qt libraries during initial installation. When installing from scratch use the online installer and select the following to install:
For starting, select at least one version of Qt libs (ex Qt 5.15.1) and the c++ compiler of choice (ex MinGW 8.1.0 64-bit).
Select Developer and Designer Tools. I kept the selected defaults.
Note: The choice of the Qt libs and Tools can also be changed post initial installation using MaintenanceTool.exe under Qt installation dir C:\Qt. See here.
In my case, it goes well after I installed CMake in my system:)
sudo pacman -S cmake
for manjaro operating system.
Another way to solve this issue (I did it on Ubuntu 16.04 but it might also work for windows and other Ubuntu versions):
While going through the installation steps, when you reach the step where you choose which packages to install via check boxes, instead of just pressing next with the default "Tools" checkbox selected also check the box for the version of QT you would like in addition to the "Tools" box. I usually check the first box which is the latest version of QT.
After doing this you should not see the "no valid kits found" issue described in this thread.
Happy Coding.
on macOS: (as of 2021)
brew install qt<latest_version> e.g. qt6
qmake --version will output:
QMake version 3.1
Using Qt version 6.0.3 in /usr/local/Cellar/qt/6.0.3_2/lib
(This is the path to the QT installation --> `/usr/local/Cellar/qt/6.0.3_2/lib`)
Go to `Preferences -> Kits -> Qt Versions
Click Add then navigate to /usr/local/Cellar/qt/6.0.3_2/bin
Select qmake executable
Go to Kits tab
Select Desktop (x86-darwin.....) in the list
Scroll down to Qt version dropdown box and select your newly installed Qt version.
Click Ok.
I had solved this issue on my Linux mint , first :
install qmake : sudo apt-get install qt5-default
go to terminal and type qmake, you should get the path of qmake
create a new project (application widget type ), when you reach
the kits part you should find desktop list item, click manage then
go to the kits tab bar and scroll down until you find a drop-down called
Qt version, click manage and paste the path there then submit.
Now the settings are done !!

qwt build - qmake build (Qt 5.3)

I want to compile the qwt library using qt 5.3. Previously I had older versions of Qt. So, when I call the Qt 5.3.0 32-bit for Desktop (MSVC 2012 OpenGL) shell and move to the directory, which contains qwt (C:\qwt-6.1.0), then perform qmake qwt.pro I get this error:
Cannot read c:/Qt/Qt5.0.2/mkspecs/win32-msvc2010/qmake.conf: The system cannot find
the path specified. Could not read qmake configuration
file c:/Qt/Qt5.0.2/mkspecs/win32-msvc2010/qmake.conf.
Error processing project file: C:\qwt-6.1.0\qwt.pro
Calling:
qmake -set QMAKESPEC "C:\Qt_5.3\5.3\msvc2012_opengl\mkspecs\win32-msvc2012\"
Does not help.
PS. Solution is found! I've tried not to do like is in qwt tutorial, simple open *.pro file by Qt Creator. After this just "build" and everything was done. Without console

c++ with Qt creator on linux: Qtversion is invalid

I just installed Qt creator to develop c++ on linux,
I try to start to build the smallest example, however I get this message:
:: error: The Qt version is invalid: Could not determine the path to the binaries of the Qt installation, maybe the qmake path is wrong?
:: error: The qmake command "" was not found or is not executable.
in the build issues window
What should I do
Thank you
In the settings window on Qt4 tab there should be automaticaly-detected path to qmake. If there isn't one (or it is invalid) you should simply give the correct path. For this you have to locate qmake using the command window in linux: whereis qmake. Then on qt4 tab you should add manually the location (I particularly added: /usr/lib/qt4/bin/qmake).
In the settings window on Qt4 tab there should be automaticaly-detected path to qmake. If there isn't one (or it is invalid) you should simply give the correct path.