Skip to Content
Programming with Qt, 2nd Edition
book

Programming with Qt, 2nd Edition

by Matthias Kalle Dalheimer
January 2002
Beginner to intermediate
522 pages
14h 36m
English
O'Reilly Media, Inc.
Content preview from Programming with Qt, 2nd Edition

Chapter 12. Interapplication Communication

In this chapter, we will see how two applications can exchange data with each other—except for writing data to a file and then reading it back, of course. This communication can be done between two Qt applications and between Qt applications and other applications that support the same protocols.

There are two techniques for the user-invoked transfer of data from one running application to another: using the clipboard and using drag-and-drop. We will examine each in turn. Of course, these techniques also work within one application, even though they might be less useful then.

Using the Clipboard

The clipboard is an area provided by the operating system or the window system in which data can be deposited. Other applications can then pick up this data. The type of data that can be put in the clipboard depends on the operating or window system, but the less common the datatype, the less likely it is that other applications can use it.

All clipboard operations are done via the class QClipboard. This class follows the singleton pattern, which means there can never be more than one instance of this class. You cannot create an object of this class yourself because its constructor and destructor are private. Instead, ask your QApplication for the QClipboard object by calling QApplication::clipboard().

Let’s first look at how you get data from the clipboard. To make this process easier to understand, imagine that there is not only one QClipboard ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

C++ GUI Programming with Qt 4

C++ GUI Programming with Qt 4

Jasmin Blanchette, Mark Summerfield
C++ GUI Programming with Qt 4

C++ GUI Programming with Qt 4

Jasmin Blanchette, Mark Summerfield

Publisher Resources

ISBN: 0596000642Supplemental ContentErrata Page