How can i make a tray icon in Linux using C++? - c++

In Windows, I can use Shell_NotifyIcon(). What is the Linux equivalent of this function?
Is it different in GNOME (gtk) and KDE (qt)? Can't find any tutorials on the Internet.

Yes, it depends on a desktop environment you're using.
In Qt (KDE), you can do this in a cross-platform manner using QSystemTrayIcon.
There is even a sample application in Qt.
In GTK, you do this with GtkStatusIcon. There is a sample application in this blog post.

All major desktop support the current XEmbed based systray icon specification. Qt and GTK both provide facilities to use that protocol in comfortable manner. Regardless of your toolkit choice the icons will appear on all desktop environments. If you use Qt you get even compatability with other platforms like Windows for free.

For Gnome, there's this tutorial and the gtkmm toolkit for C++
EDIT: This is for panel applets, you asked for system tray icons. They're similar, but not quite the same. Go with Reed's answer.

Related

c++ gui window cross platform

I would like to make c++ that will work both on Linux and windows as I understand if I use the win32 template in visual studio then it will only work on windows is there something built into c++ like java's jframe that I can use. Also I would like to use any external library at this time.
Here are some cross platform alternatives QT, wxWidgets, Ultimate++. I have used QT, it is intuitive with a huge collection of tools to use in your code. The others are also popular but I have never used them.
I make used of wxWidgets due to it's cross platform and even cross architecture, native look on the OS where it appear. Binary application yields by wxWidgets is small enough thus make it possible to linking statically as portable application. Qt produce huge binary if linked statically (and may be violate qt licensing scheme).
Another reason are licensing flexibly, well documentation and supported by huge community arround the world. wx is considered as mature framework since it first release about 20yrs ago. It's use standard C++ syntax and preprocessor that will make you easily switch from plain C or C++. Complete library are available ranging from appeal window GUI, string, network, stream, webview, xml, and wx is playing very well with 3rd party library as such database SOCI, Asio, etc ....
You may try start to code with wxWidgets easily using Eclipse-IDE and wxFormBuilder as GUI designer. Plese check my experience for ease setup it's IDE+Toolchain. This wx installer can be used do develop, test and run wx application on Linux desktop, and then deploy the binary on Raspberry Pi is available for another board target beside Linux x86_64.
http://yasriady.blogspot.co.id/2016/01/raspberry-pi-toolchain.html
There is a cross-platform application & UI development framework called Qt. I think it meets your requirements. Click here for more info.
There is a long list of both active and dead cross-platform C++ UI libraries here: https://philippegroarke.com/posts/2018/c++_ui_solutions/

How to get a context menu for file system actions in Qt?

Is there any way to get a system context menu for files?
I need to have all the commands from system menu, not only simple operations like copy/paste/rename, but also some non-standard, like Dropbox actions.
I am using Qt 5.x on Windows, but a solution for Mac OS would be useful, too. If the answer requires a library independent of Qt, that is ok too.
Qt does not provide such feature. But you could use native API for each platform. See
How do you show the Windows Explorer context menu from a C# application?
for getting Windows explorer menu.

Alternate of win32 framework for windowing system on windows

I want to develop a custom window system in c++ that should not depend on win32 library. As an example, Google Chrome has an interface that is not similar to windows own interface. Similarly MPCstar and adobe products have their own interfaces. Please help me where to start for such a project?
You can use cross platform
Qt
or
wxWidgets
but in my opinion Qt is better.
Qt is awesome even if you don't need cross platform support. I assure you after using it you won't understand how anyone could ever develop native GUI on frameworks like Win32 and MFC. Its only shortcoming is the size of the DLLs you'll have to distribute with your app.
BTW is C++ a prerequisite? if not, and you only need windows, use .Net.
I believe Qt should do the trick. I've never used it myself but it is platform independent. I know a few applications that use it, and it seems fine.
Qt and WxWidgets are the better options. And since its GUI I think Qt performs better and has greater support and lots of libraries.
Find Qt here!

Can you program a GUI in C++ that works on both Windows and Linux operating systems?

I have been learning C++ for a while now, and so far I love it. But I have been stuck at the console application level. I have built C# programs for a few years so I love having a GUI and not do everything via console.
Console programs when compiled will work on both windows and linux, which is great. When I was searching GUI C++ tutorials I could only find tutorials for windows specific GUI applications.
So my question is this, can you program a GUI in C++ that when compiled with run on both windows and linux? If this is not possible, can someone point me to a great place to learn windows and linux GUI?
I suggest you to use Qt by Nokia:
http://qt.nokia.com/products/
It is free, very powerful, very easy to use, and well designed. And there is also a Visual Studio Add-in available:
http://developer.qt.nokia.com/wiki/QtVSAddin
but you can use their own cross-platform IDE called Qt Creator as well.
You can use wxWidget library.
Yes, you need to use a cross platform GUI toolkit like WxWidgets
gtk and gtkmm http://www.gtkmm.org/en/
Indeed, using cross-platform GUI libraries (like Qt, Gtk, WxWidgets) help you to have the same source code working on Linux and Windows. I recommend Qt if coding in C++.
But there is no way to build an executable working on both systems (unless you use wine to emulate Windows on Linux, which I don't recommend in your case).

Which GUI library is used to develop Mozilla Firefox?

Which GUI library is used to develop Firefox?
Qt? GTK+? Windows native?
Firefox uses a number of GUI toolkits, including the native Windows one, as well as GTK+ for X platforms. Sadly, there is no official support for Qt.
I heard that firefox is using their own GUI based off of XML and its called XUL. At least that's what it sounds like if your read their articles on XUL.