Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8720907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:08:05+00:00 2026-06-13T07:08:05+00:00

I am building an editor using C++/Qt which has a click-and-drag feel to it.

  • 0

I am building an editor using C++/Qt which has a click-and-drag feel to it. The behavour is similar to schematic editors (Eagle, KiCAD, etc), Microsoft Visio, or other programs where you drag objects from a toolbar into a central editing area.

My problem is that when the user clicks inside the custom widget I want to be able to select the instance of the box-like object and manipulate it. There will also be lines connecting the boxes together. However, I can’t decide on an efficient method for selecting those objects.

I have two main thoughts on how to do the programming for this: The first is that the widget which is drawing the entire editor would simply encapsulate every one of the instances of the box. The other is to have each instance of the box (which is in my Model) carry with it an instance of a QWidget which would handle rendering the box (which would be in my View…but it would end up being strongly attached to the model). As for the lines connecting them, since they don’t have a square bounding boxes they will have to be rendered by the containing widget.

So here is the summary of how I see this being done:

  • The editor widget turns into a container which holds the widgets and the widgets process their own click events. The potential issues here are that I don’t know how to make the custom widget turn into a layout which lets click-and-drag functionality.
  • The editor widget takes care of all the rendering and processes the mouse clicks (the easier way in that I don’t have to worry about layout…its just selecting the instances efficiently that I don’t know what would be best).

So, now that there is a bit of background, for the 2nd method I plan on having each box-like instance having a bounding rectangle and the lines being represented by 3-4 pixel wide bounding rectangle segments (they are at 90 degree angles). I could iterate through every single box and line, but that seems really inefficient.

The big question: Is there some sort of data structure I can hold rectangles in and link them to widgets (or anything else for that matter) and then give it two coordinates (such as mouse coordinates) and have it spit me out the bounding box or linked object that those coordinates are inside of?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T07:08:06+00:00Added an answer on June 13, 2026 at 7:08 am

    It sounds like your real question is about finding a good way to implement your editor, not the specifics of rectangle intersection performance.

    You may be interested in Qt’s “Diagram Scene” example project, which demonstrates the QGraphicsScene API. It sounds like a good fit for the scenario you describe. (The full source for the example ships with Qt.)

    enter image description here

    The best part is that you still don’t have to implement hit testing yourself, because the API already provides what you are looking for (e.g., QGraphicsScene::itemAt()).

    It’s worth noting that internally, QGraphicsScene uses a simple iterative method to perform hit tests. As others have pointed out, this isn’t going to be a serious bottleneck unless your scenes have a lot of individual items.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building a HTML editor using TinyMCE but the HTML file (before TinyMCE has
I'm building a wysiwyg-editor with an editable iframe using document.execCommand() . Now i need
A common issue when building Content Management Systems for end-users using WYSIWYG Editors like
I'm building a WSS site which has to show SVG files stored on WSS.
I am trying to install the yi editor using cabal-install, which in turns installs
I'm building an app which searches the web using search engine. I have one
I am building a database editor/line-of-business tool for a client using .NET 4.0, and
I'm now building a developers editor using Lazarus and as every good developers editor,
Do you know of a tab widget that has built-in drag+drop reordering? I'm building
I'm building a webapp (using java,spring,freemarker and tiles) with tinyMCE editor. I've added all

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.