QSystemTrayIcon in ubuntu, sni-qt - c++

I'm using Ubuntu 12.04 64-bit.
I built qt libraries (qt-everywhere-opensource-src-4.8.2) and want to use them when building my application, and deploy them with my application.
I want my app to have system tray icon, so I'm trying to use QSystemTrayIcon class, but the icon doesn't show.
After some research I found out that it has something to do with sni-qt plugin. But I couldn't find any information on how to use it in my code. Or the qt libs must be patched to use it? Because if I link to qt libraries preinstalled in the system, the icon shows.
The question is how can I make system tray icon appear and function using my manually built qt libraries? Is it possible

Qt will refuse to load a plugin compiled against a different Qt version (or with a different compiler, or a different Qt setup). Hence, you need to build that plugin as well using the same Qt version your application is using. Grab its sources and compile it.

Related

Can't import/configure Qt project

I have cloned the following GitHub project to my hard drive.
https://github.com/leozide/leocad
I have also installed Qt Creator 4.5.0. However, when I try to load the project in Qt Creator, it says there are no valid "kits", and will not let me configure the project. (Presumably, this is a necessary step before I can build the project.)
What do I need to do to get this to work? Thanks.
Windows 10 Home, Qt Creator 4.5.0
Qt is a cross platform framework, thus supporting a bunch of c++ compilers like MinGW GCC, Clang ...etc. a Kit is a set of Qt packages designed for a specific C++ compiler and implements the Qt libraries for that compiler, this is what you need to compile your project in Qt creator .. and they are not part of Qt Creator itself, they must be downloaded. below steps are suitable to get Qt fully functioning.
The Qt open source.
There are two ways to get Qt, the first is to download the source code packages/files and build Qt yourself (but this would be needed if you have a reason to build qt packages from sources yourself). this not covered here.
Steps to install and Configure prebuild Qt Open Source.
Download Qt Online Installer for Windows, usually from this location Qt Online Installer for Windows, this is an online installer for Qt.
Run the downloaded installer, it will guide you through few steps like creating an Qt account and logging in ...
You will end up to the component selection screen and this is the most part.
Expand the Qt Selector tree, you will get 2 groups, A list of available prebuild Qt versions, And to the bottom a Tools selector tree.
make your selection of which Qt version you wish to be downloaded and installed.
Then expand the tree for that version and Choose the components of your interest, these are package kits for a list of compilers .. (For example: a windows user might choose "MinGw x.x.x 32" suite for development under windows .. and "Android" component to develop Android Apps on Qt Creator.
Go down to the Tools tree, expand and select which components to download and install. For Windows usually you need : Qt Creator Debugger, MinGW x.x.x (same as above) and Qt installer framework (which is a maintenance tool for Qt upgrades ...etc).
If you have selected MinGw kit in Qt Version , then you must download the corresponding MingW framework, from Tools branch, unless you have it.
After all selections are made press Next and complete the installation.
Note: with a clean installation of Qt, it configures itself automatically and no further configurations are needed -> Kits are automatically configured based on your installed components.

C++, Code::Blocks, which project type should I choose for GUI in both windows and macos?

I'm trying to create a simple GUI program that stays on top and shows an image plus few buttons with variable opacity for the whole window to use like onion skin over other programs.
after installing Code::Blocks I'm facing lots of choices for the project type and I have no idea which one I should choice to be able to build for both windows and macOS platforms.
I'm trying to make it a single file program or contain everything in the same folder, without the need for anything to be installed, that's why I've chosen C++ after reading about other possible solutions, I'll appreciate any information about that topic as well.
On Windows you would normally use the Win32 GUI project option, which will use the WinAPI and thus only be compatible with Windows. If you want to support both Windows and MacOSX with the same code base you need to use a platform independent GUI framework such as QT or GTK+.

Make "Add Qt Sources" work for Qt SDK on Linux (NOT built from source)

This is similar to my question about Step into Qt Sources from Qt Creator on Windows (NOT built from source), but I can't make it work for Linux.
Instead of building from source, I have downloaded the Qt SDK installer, and I've installed Qt to /opt/Qt, and I have the sources at /opt/Qt/5.4/Src.
I cannot step into Qt Sources, so I tried adding a Source Mapping using "Add Qt Sources":
I have tried mapping /var/tmp/qt-src to /opt/Qt/5.4/Src, /opt/Qt/5.4/Src/qtbase, and /opt/Qt/5.4/Src/qtbase/src, none of which worked.
What am I doing wrong? Is the source mapping not /var/tmp/qt-src, or is the target mapping wrong? Does "Add Qt Sources" work at all for the Qt SDK?
I saw a suggestion in a forum thread that it's because the Qt SDK for Linux ships only stripped binaries, while it ships both debug and release DLLs for Windows (which would explain why it worked for Windows, but not for Linux).

How to organize Qt DLLs with Qt-based dependency

I have a Qt application using Qt 4.8.5. This application is dependent on a DLL that was built using Qt 4.6.0. Let's call it "MyDLL.dll".
I cannot rebuild MyDLL.dll to update it to a more current version of Qt. Since both my application and MyDLL require the QtCore and other DLLs, and the versions are different, how do I organize my files such that they don't conflict?
MyDLL is required at startup, so I can't use any delay load methodologies.
edit: To be clear, this question came up because the MyDll.dll was built using a custom Qt 4.6.0 from modified source, and my application is using a custom build of 4.8.5. The modifications weren't necessarily the same in both versions, so I didn't want to assume that I could still use the 4.8.5 DLLs. Turned out that it worked out in this case, but the question stands.
You shouldn't be having any issues. Qt maintains binary compatibility over minor and patch releases (see http://qt-project.org/wiki/Qt-Version-Compatibility) and an application/DLL built with 4.6.x will run fine when bound to 4.8.x runtime.
Your MyDLL.dll built with 4.6.0 will run with 4.8.5 runtime DLLs.
Your application built with 4.8.5 will run with 4.8.5 runtime DLLs.
Your application will run fine with MyDLL.dll as long as you are using the same interface you've always been using.
If you are seeing issues it is because of something else, and you will need to clarify exactly what problem you are having.
If you are not seeing issues and are just asking preemptively, then 1) just proceed as normal with no special considerations, and 2) you should have tried it first!
Welcome to DLL Hell! :(
This is a huge problem under Microsoft windows, since the standard isn't to build version information into the DLL file name (like with Linux .so files).
You won't be able to accomplish what you are after if you link directly against "MyDLL.dll" since it will be looking for QT DLLs (like QtCore, QtGui, etc). The stock Qt DLLs contain no version decoration in the filename, so there will be a conflict as to which one to load. Also, you will likely not be able to link correctly in the first place (due to the conflicts. Qt doesn't play well with older versions).
The only possibility might be to create a separate executable that links against Qt 4.6.0 and MyDLL, and use some out-of-process communication between your main app and the server. COM might work in this case, but it largely depends on what your dll actually does.
The only other course of action would be to downgrade your main application and fix it at Qt 4.6.0.
Jason C's answer got it right. Also note the following:
MyDll.dll must be compiled with the same compiler version as the rest of your application.
The version of Qt used to build MyDll.dll should have had the same major configuration flags as the version of Qt that you're currently using. Things such as Qt namespaces, QThread support, etc. must all be the same.

Create Qt UI forms as a shared library in Qt Creator and using them in Eclipse C++ project

I am developing an application and the main IDE is Eclipse Juno(CDT) on Red Hat Enterprise Linux 6.
I have the following constraints:
Application must be developed on Eclipse (Non-GUI part)
Must Use Qt4 for GUI
Application target platform is Red Hat Enterprise Linux Server version 6.3
I am new to Linux Development Environment, Eclipse and Qt.
What I have done:
I have developed the main application on Eclipse.
I have created modules like interacting with hardware as shared libraries.
What I want to do (if possible, and practical):
I want to create the GUI module of the application using Qt Creator, as a library and use it in the main application on Eclipse.
What I am trying:
Created the GUI in eclipse without using any .pro files or Qt Creator. But since I am new to Qt and Eclipse and Linux, and time constraints, I want to make it quicker, easier and well planned approach to complete the tasks. This looks very tedious (obviously) as I am better off using an IDE and visual tools to create GUI.
Can someone help me with the following:
Am I doing the things right, is my approach of creating GUI module as a shared library and using it in another application a naive approach?
If I missed out detailing anything or if you need more info please let me know.
Thanks.