[Solved] Send text to clipboard for external use

Discussion forum for C++ and script developers who are using the QCAD development platform or who are looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files, scripts and screenshots.

Post one question per topic.

Post Reply
ikua
Junior Member
Posts: 15
Joined: Tue Apr 25, 2023 4:07 pm

[Solved] Send text to clipboard for external use

Post by ikua » Fri Jan 26, 2024 10:18 am

Hello!

I am trying to find a methode to send text from qcad script into the clipboard to paste it into an other app (excel). I could find not solution not with RInterface::clipobard also not with clipboardoperation. My last try was the following which did not work out. Any suggestions?

Code: Select all

var appWin = EAction.getMainWindow();
	var di = this.getDocumentInterface();
	var op = new RAddObjectsOperation();
	appWin.handleUserMessage("1")
	di.applyOperation(op); //tryout if di works
	var hui = di.getClipboard()
	appWin.handleUserMessage("222")
Would be happy about a hint. (I can save the information to an file, but for speed reasons i am searching also for a clipboard solution).
Last edited by ikua on Fri Jan 26, 2024 1:26 pm, edited 1 time in total.

User avatar
andrew
Site Admin
Posts: 9063
Joined: Fri Mar 30, 2007 6:07 am

Re: Send text to clipboard for external use

Post by andrew » Fri Jan 26, 2024 10:29 am

You can use QClipboard from Qt:

Code: Select all

var cb = QGuiApplication.clipboard();
cb.setText("My text");
di.getClipboard() returns the QCAD internal clipboard (for geometry entities).

ikua
Junior Member
Posts: 15
Joined: Tue Apr 25, 2023 4:07 pm

Re: Send text to clipboard for external use

Post by ikua » Fri Jan 26, 2024 1:26 pm

works like charm!! thanks for fast reply.

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”