QT File menu not integrating into title bar - c++

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.

Related

Is there a way to run qmake with QT 5.7 and above?

I have a project I made with Qt 5.7 in QtCreator, but now I would like to be able to build the project with qmake in the terminal rather than through QtCreator. However, I can't get qmake to run with Qt 5.7.
Following the instructions in this webpage, I can switch qmake to qt5 but qmake -v still says I'm running QT 5.2.1. How can I switch this to Qt 5.7?
Edit: Adrien's second comment worked. I was unable to get qmake to switch to Qt 5.7, but I can simply directly call the qmake that came installed with Qt 5.7 like this:
/home/<user>/Qt5.7/Qt5.7.0/gcc<something>/bin/qmake
Short answer: yes of course :)
Each Qt build builds its own qmake binary. So if you already built/installed Qt 5.7, it means you are simply pointing to your previous Qt version's qmake. You can access any Qt version qmake executable from your Qt install folder, i.e. for Linux:
/home/<user_name>/Qt/Qt<version>/<compiler>/bin/qmake
Note that the path to Qtfolder, and its name may vary depending on the settings you used for the first installation.
If you want to use a global setting instead, and if qtchooser -list-versions lists the Qt version you want to use, then make sure to set export QT_SELECT=<Qt version> (without spaces) in the same terminal as the one you use qmake from afterward. Environment variables are not kept when you close your terminal, or shared between different terminals.
export QT_SELECT=qt5
qmake

Cannot add qmake files to Qt Versions [armhf]

I installed qt4-qmake:armhf and qt5-qmake:armhf but I cannot add it to Qt Versions in Qt Creator manually. I get error:
The qmake executable could not be added: qmake""is not an executable.
What else should I try?
I am using windows right now, but searching file list for the 2 packages in debian repository online it seems that that qmake is located in:
/usr/bin/qmake-qt4 for qt4
/usr/lib/arm-linux-gnueabihf/qt5/bin/qmake
for qt5

openCV in Qt Creator on Mac

I am new to C++ so this is probably a simple fix, but I have not been able to run my program even after reading Stack Overflow's many posts regarding openCV and Qt creator. This is now my 4th day trying to get openCV working in Qt creator, so any help would be greatly appreciated!
I know openCV is installed and working on my computer because I am able to build and run programs using it by running g++ pkg-config --libs --cflags opencv -o name name.cpp in terminal, just as long as I don't try to use openCV in Qt creator. I installed openCV through Homebrew and downloaded Qt creator from its website. I also have qt installed by running "brew install qt" in terminal.
I tried linking openCV to my Qt project by editing the project file which now reads:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = opencvTestQT2
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
QT_CONFIG -= no-pkg-config
CONFIG += link_pkgconfig
PKGCONFIG += opencv
But upon trying to run it I get the error:
opencv development package not found
I have also tried adding to my project file lines such as:
INCLUDEPATH += /usr/local/Cellar/opencv/2.4.11_1/include/
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.10
LIBS += -L/usr/local/Cellar/opencv/2.4.11_1/lib -lopencv_imgcodecs -lopencv_highgui
but none of them allow my program to be built.
I am using a Mac running version 10.10.4, openCV 2.4, and Qt Creator 3.4.2 in case that helps.
Thanks in advance
Click on projects on the left pane -> Build & Run -> on Build Environment, add Path to /usr/local/bin in order for qt creator to find the pkg-config.
as Dae Choi said, the pkg-config is not found. Doing that procedure will work. Just remember to update the run as well.
This error will show:
Starting /Users/sgb/build-imagenes-Desktop_Qt_5_9_1_clang_64bit-
Debug/NBasic.app/Contents/MacOS/NBasic...
dyld: Symbol not found: __cg_jpeg_resync_to_restart
Referenced from:
/System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
Expected in: /usr/local/lib/libJPEG.dylib
in /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
The program has unexpectedly finished.
Just update in Projects -> Build & Run -> Run -> DYLD_LIBRARY_PATH to unset. Save and compile again. There are other thread where you can check as well.
Qt application throws “dyld: Symbol not found: __cg_jpeg_resync_to_restart”

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

qt gui project in eclipse using qt plugin

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.