Copy text selection to clipboard in Windows using Qt and C++ - c++

I would like to allow the user to insert a selected text from any source or application into my Qt application using the middle mouse button.
This functionality is already available with the help of the QCliboard class on operating systems with X11 Window System. According to the Qt documentation, this does not work on Windows because Windows does not support the global mouse selection.
Is there a way to make this functionality available in Windows as well? Can this be achieved with a Qt and C++ implementation? Is there possibly a C++ library that I could integrate which offers this functionality?

Related

How to create an Evernote kind of widget for global menu of a MacOS/X desktop using QT?

How to create an application which stays in top of MacOS, something similar to below image. You can see the Evernote elephant icon.
I don't want to use xcode - because my application already built in QT, it has nice GUI, now I wanted to add extended feature something similar to Evernote. If I click on an elephant it will open a dialog box to write notes. In my case- it's a simple event like on/off buttons.
I have tried and created GUI widget apps but how to make one which resides like Evernote app ?
A custom pop up menu like the one pictured can be done several ways in Qt.
QML is the most modern way of making the menu with the customized styling you are looking for.
Apply the appropriate flags to the window/widget so it appears as a popup.
The same effects can also be done in QWidgets, but takes more code and probably will take longer to make. The flags you are looking for will be found under Qt Window Flags and/or under Qt Widget Attributes.
The stock stylings for Qt for different OS's deal mostly with title bars, status bars, buttons, drop downs, etc.
The base styles for Mac can be found here:
http://doc.qt.io/qt-5/gallery-macintosh.html
Once you go to a customized popup, you have to draw all of it yourself... but the native drawing elements in Qt are friendly enough and get you that look you are trying to do.
There are even some tools for exporting from Photoshop or Gimp directly to QML.
http://doc.qt.io/qtcreator/quick-export-to-qml.html
Hope that helps.
You are looking for a tray icon. Qt implements it in QSystemTrayIcon.
Further information
You may take a look at the System Tray Icon Example.
Many StackOverflow posts exist on this topic.
If you already have a program written for Qt, then you can compile and run it under MacOS/X much the same way you could compile it under (whatever OS you're using now). You'll need to install Xcode because Xcode includes the C++ compiler (clang) you'll need in order to compile your Qt program, but you don't have to use the Xcode IDE if you don't want to. Rather, you can either use the QtCreator IDE under MacOS/X, or you can simply open up a Terminal window and do a "qmake ; make" in the directory where your Qt-based program's .pro file is, and build it from the command line that way.
If, on the other hand, your question is actually about how to add an icon to the global menu of a MacOS/X desktop, then I don't think Qt has an API for that, so you'll need to drop down to using one of MacOS/X's native APIs. That will probably involve learning some Objective-C (or Objective-C++, if you prefer), but integrating a bit of Objective-C/C++ into your Qt app is doable with a bit of work.

Compiled Qt for windows is win api at Low Level

Qt is cross platform c++ Gui Library.Code once and compile for different Platform. Let's for instance, I have compiled a Project(decent text editor with few tool bar) or any such program for Windows(x86).
Statement 1: The Program.exe entry point will be WinMain.
Statement 2: The Text editor and tool bar will created using "CreateWindow" win32 api. Qt have its own class to implement but to ask OS(Windows) for creating a tool bar or text editor, Program exe interface with OS(Windows). OS understand what it know it does not know anything about Qt class,so to create tool bar or text editor program have to use win32 api.
Statement 3: All event processing( button click, mouse click) will handles using windows messeging system.
Note: It may seem i am viewing every thing with win32 api glass on my understanding.
Correct. The WinMain implementation is provided by the Qt library.
Half correct. The top-level windows are created using CreateWindow. Child widgets, such as a non-toplevel toolbar are Qt's own widgets and are opaque outside of your application. They are exposed only via the accessibility APIs. This allows you to create more widgets than Windows would be able to deal with. A million child widgets is doable, if not particularly fast.
Correct - there's no other way. Of course Qt immediately translates native messages into QEvent instances and dispatches them internally to various QObject instances. In Qt-land, all events must be received by a QObject instance.
You're incorrect in your assertion that winapi has anything to do with the kernel. Winapi is implemented by a bunch of user-space DLLs. You could implement those DLLs yourself. Those DLLs themselves call into the kernel using the native api. That's the API actually exposed by the kernel to the user space.

Terminal to open a popup window in C++

My c++ application needs to display a message via a popup window or an alternative. My application is running on Ubuntu 12.04 version. Can I program the application to open a Ubuntu type popup window? If possible, how?
Do I need to use gnome window or something like that?
The simplest way to display a popup from a program that doesn't otherwise use a GUI, is probably just execute a command-line tool that does the work:
to display a notification with no buttons, you can use notify-send
system("/usr/bin/notify-send MessageSubject \"message body here\"");
if you want buttons so the user can give a response, you could use the (much uglier) xmessage
system("/usr/bin/xmessage")
(see each tool's manpage for all their options)
The alternative is really to use a full GUI framework (probably gtk+), and that's not typically a small change.
For example, you can use libnotify directly (giving you the same basic capabilities as notify-send, but more control), but this also depends on glib. So, now you've added two external dependencies when you could just have run system.
In order to display the popup or any kind of window, you will have to reference either gtk+ or qt libraries in your application/program. gtk+ is advisable, since the ubuntu unity desktop is also based on gtk+ - this way your program will have lesser overhead and more performance gain while running on ubuntu. You can either use the default C library (libgtk2.0) or the gtkmm (libgtkmm) for C++.
You can get more information on how to refer these libraries, initialize gtk_main in your main() function, etc. at this place: http://www.gtk.org/documentation.php

Skin a dialog box

I am writing a C++ application and I have a Login Box that's shown in a regular Dialog Box Frame. I see that some people can SKIN the entire dialog box and makes it look really nice. I was wondering if anyone can give me some pointers as to how to do that.
I'd need more details to give you a good answer.
The answer very much depends on which OS you're using and how you're programming your GUI (for example on Windows - plain Win32, MFC, ATL, Qt, Windows Forms, WPF etc etc).
If you're just using the Windows API here's a link to get you started.
http://www.codeproject.com/KB/dialog/skinstyle.aspx
Beware: custom skinning dialog boxes can be a very large task if you want to customise the look of every control as you end up writing very complicated custom controls.
Alternatively do you just want to make sure that your dialogs appear with Windows XP visual style rather than pre-XP style? This will require changes to your application to use the new common controls and visual style. Note that this changes the behaviour of some Windows APIs and can potentially have side effects (see ISOLATION_AWARE_ENABLED).

Qt and native menus

Does Qt support interaction with the native menu bar of an arbitrary window (i. e. QWidget) on Windows and Linux?
It looks like Qt treats the menu as just another child widget to be placed on the parent window. That is, to have a menu bar , I must reserve some space for it in the window's client area. That makes no sense on Mac, with its menu on the top of the screen. On Windows, it makes little sense - the menu, as implemented by the system, is outside of the client area. Not sure what's the native model on Linux.
Qt supports native menues on Mac and on Windows. It may seem when looking at the forms in Qt Designer, that Qt menues on Mac are non-standard, but they aren't. Qt had made a great deal to deal with menue differences between the supported platforms and they work very well.