Creating a tool that gets coordinates of selected object

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
s4eed
Junior Member
Posts: 18
Joined: Fri Sep 27, 2013 3:23 pm

Creating a tool that gets coordinates of selected object

Post by s4eed » Mon Nov 18, 2013 9:44 pm

Hi friends. Specially dear Andrew!
I need to create a new tool that extracts properties of selected object(x, y, width, height) and processes them and displays a result to the user. For example suppose this scenario :
1-User selects a car in his map ( opened in QCad )
2-User selects my tool(from toolbar or menubar)
3-(Here is the problem!) My tool gets x,y,w,h of selected car and produces a result based on these four numbers and displays a message box to the user.

I can create new tool (I've read this : http://www.qcad.org/doc/qcad/3.0/develo ... _tool.html!) But first of all I want to know whether it's possible doing such a task completely in Qt(processing the x,y,w,h numbers)?
Second I need a start point for how to do this task?
Thank you guys!

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

Re: Creating a tool that gets coordinates of selected object

Post by andrew » Mon Nov 18, 2013 9:58 pm

You might want to have a look at the bounding box example which is very similar:

scripts/Misc/Examples/DrawExamples/ExDrawBoundingBox/ExDrawBoundingBox.js

(Online at: https://github.com/qcad/qcad/blob/maste ... dingBox.js)

This is no problem with the Qt / QCAD script environment.
Displaying a message box is as simple as:
QMessageBox.information(null, "Title", "My message...");

s4eed
Junior Member
Posts: 18
Joined: Fri Sep 27, 2013 3:23 pm

Re: Creating a tool that gets coordinates of selected object

Post by s4eed » Mon Nov 18, 2013 10:10 pm

:D Really thank you ! But how can I create a tool completely in Qt.That's my problem, not showing a message :D . Is there any tutorial?

s4eed
Junior Member
Posts: 18
Joined: Fri Sep 27, 2013 3:23 pm

Re: Creating a tool that gets coordinates of selected object

Post by s4eed » Mon Nov 18, 2013 10:11 pm

Got It ! I can use every Qt classes in my .js file. Is it true?

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

Re: Creating a tool that gets coordinates of selected object

Post by andrew » Mon Nov 18, 2013 10:18 pm

Yes. Almost the entire Qt API is available in scripts. If you need help or an example for a particular class, just search through the scripts directory of QCAD - chances are there is already a script showing how to use that class somewhere.

s4eed
Junior Member
Posts: 18
Joined: Fri Sep 27, 2013 3:23 pm

Re: Creating a tool that gets coordinates of selected object

Post by s4eed » Mon Nov 18, 2013 10:22 pm

I've never seen someone conscientious like you Andrew. Again thank you.

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”