Qt/PyQt中操作系统剪贴板(clipboard) - CSDN博客 https://blog.csdn.net/vagrxie/article/details/5250507
# TODO: not implemented yet
item_selected=self.tableWidget_serpre.currentItem().text()#选中item的文本值
#colss=self.tableWidget_serpre.columnCount()#表的列数
self.lineEdit_idname_2.setText(item_selected)
#——————复制到剪粘板clipboard,用的是python3.6,qt5,经验证可行。
clipboard = QtGui.QGuiApplication.clipboard()#实例化clipboard对象
#剪贴板中已经有数据了,但不是简单的数据,还包含各种格式,用print(clipboard)显示的是地址
clipboard.setText(item_selected) #print(type(clipboard)),结果:<class 'PyQt5.QtGui.QClipboard'>,
data_a=clipboard.mimeData() #print(type(data_a)),<class 'PyQt5.QtCore.QMimeData'>
print(type(clipboard))
print(type(data_a))
<PyQt5.QtGui.QClipboard object at 0x087BBB70>
<PyQt5.QtCore.QMimeData object at 0x09A4B4E0>
Python如何获取Windows剪贴板内容并判断类型? - 知乎 https://www.zhihu.com/question/37741420/answer/76017786
python - PyQT - copy file to clipboard - Stack Overflow https://stackoverflow.com/questions/6062382/pyqt-copy-file-to-clipboard
The QApplication class manages the GUI application's control flow and main settings.
QApplication specializes QGuiApplication with some functionality needed for QWidget-based applications. It handles widget specific initialization, finalization.
For any GUI application using Qt, there is precisely one QApplication object, no matter whether the application has 0, 1, 2 or more windows at any given time. For non-QWidget based Qt applications, use QGuiApplication instead, as it does not depend on the QtWidgets library.
Some GUI applications provide a special batch mode ie. provide command line arguments for executing tasks without manual intervention. In such non-GUI mode, it is often sufficient to instantiate a plain QCoreApplication to avoid unnecessarily initializing resources needed for a graphical user interface. The following example shows how to dynamically create an appropriate type of application instance:
Detailed Description
The QGuiApplication class manages the GUI application's control flow and main settings.
QGuiApplication contains the main event loop, where all events from the window system and other sources are processed and dispatched. It also handles the application's initialization and finalization, and provides session management. In addition, QGuiApplication handles most of the system-wide and application-wide settings.
For any GUI application using Qt, there is precisely one QGuiApplication object no matter whether the application has 0, 1, 2 or more windows at any given time. For non-GUI Qt applications, use QCoreApplication instead, as it does not depend on the Qt GUI module. For QWidget based Qt applications, use QApplication instead, as it provides some functionality needed for creating QWidget instances.
The QGuiApplication object is accessible through the instance() function, which returns a pointer equivalent to the global qApp pointer.
QGuiApplication's main areas of responsibility are:
- It initializes the application with the user's desktop settings, such as palette(), font() and styleHints(). It keeps track of these properties in case the user changes the desktop globally, for example, through some kind of control panel.
- It performs event handling, meaning that it receives events from the underlying window system and dispatches them to the relevant widgets. You can send your own events to windows by using sendEvent() and postEvent().
- It parses common command line arguments and sets its internal state accordingly. See the constructor documentation below for more details.
- It provides localization of strings that are visible to the user via translate().
- It provides some magical objects like the clipboard().
- It knows about the application's windows. You can ask which window is at a certain position using topLevelAt(), get a list of topLevelWindows(), etc.
- It manages the application's mouse cursor handling, see setOverrideCursor()
- It provides support for sophisticated session management. This makes it possible for applications to terminate gracefully when the user logs out, to cancel a shutdown process if termination isn't possible and even to preserve the entire application's state for a future session. See isSessionRestored(), sessionId() and commitDataRequest() and saveStateRequest() for details.
Since the QGuiApplication object does so much initialization, it must be created before any other objects related to the user interface are created. QGuiApplication also deals with common command line arguments. Hence, it is usually a good idea to create it before any interpretation or modification of argv is done in the application itself.