How to implement Snap to grid in QT

Hello everyone, I want to implement snap to grid functunality in my project. I have different entitites which are drawn on graphicsview on mouse click . Also there is grid drawn with the drawBackground method. How can I implement Snap to it. 

This forum is only for SQL Server Reporting Services. Is your scenario related to this topic? Can you clarify your requirement?

Similar Messages

  • Hi.  I have Snap To Grid and By Kind enabled in Lion but it's not working.  When I trash an icon, instead of snapping the remaining icons to the By Kind grid, a space is left where the trashed icon was.  Any suggestions on how to get Snap To Grid working?

    Hi.  I have Snap To Grid and By Kind enabled in Lion but it's not working.  When I trash an icon, instead of snapping the remaining icons to the By Kind grid, a space is left where the trashed icon was.  Any suggestions on how to get Snap To Grid working?

    Where are you talking about the Desktop?
    I don't see where it is possible to set both Snap to Grid and By Kind they seem to be mutually exclusive.
    And then
    If I have Snap to grid set I get the behavior you describe. If I have By Kind set the icons stay together and close up the space from the deleted icon.
    regards

  • How do I Snap to Grid permanently?

    Good day to you.  Something about my iMac I find (minorly) irritating, so I would like your input, please.
    Each day, I get the crossword puzzle from the New York Times.  On my iMac, these have their own folder that I keep on my Desktop.  Both during the day _&_ upon shutdown the previous night, as View I say, Snap to Grid.
    But Lo & Behold when I start-up my iMac in the morning, the files in my Crosswords folder show just a-little Out of-Place.  So _daily_ to show my Crosswords folder the way that I want, I _must_ say, Snap to Grid.  (This grows Tiresome, as-in Droll.  ZZZZ.)
    Does anyone else notice this with his or with her files in the Finder?  Please let me know if you do.  Thank you.
                        (Were I a Skeptic I would say, "This bad behavior is just a reason to Upgrade in the future, where Upgrading = More Money."  Yuck!)

    Make sure you follow the exact mapping I posted.  The actual file will be named:  com.apple.finder.plist.
    To repair permissions:  The short version:
    Go to Applications>Utilities>Disk Utility and select your volume and then select Repair Permissions.
    Same directions are also in the OS Mac Help Menu.

  • How can I snap anchor points to grid?

    I am trying to snap anchor points to the grid so I don't have to eye-ball the curves. Is there a way that I can do this?

    Luke,
    How about View>Snap to Grid?

  • How to implement a snap grid?

    I've been watching these forums for a while now, and I don't think I've seen anyone bring this up. I need to implement a toggleable snap grid, basically like might be in a paint or CAD program. However, I have no clue where to start or how I would begin to attempt such a thing in swing. Has anyone done this, or have any suggestions of what API functions might provide what I need? Thanks,
    xanatos387

    Not sure if you're still having problems...here's some code to allow 'snap to grid' drawing. I've removed alot of stuff for clarity, but you should still get the 'gist' of how it works.
    -Brian
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class DotTest extends JPanel implements MouseListener, MouseMotionListener {
         private int dotSize;
         private Shape aShape;
         private boolean inDrag = false;
         private int xOffset, yOffset;
         public static void main(String[] args) {
              int dotSize;
              if (args.length < 0 )
                   dotSize = 5;
              else
                   dotSize = Integer.parseInt(args[0]);
              DotTest t = new DotTest(dotSize);
              JFrame f = new JFrame("Dot Size Test");
              f.setSize(300, 300);
              f.getContentPane().add(t, BorderLayout.CENTER);
              f.show();
         public DotTest(int d) {
              super();
              dotSize = d;
              buildGUI();
              System.out.println("Using dotSize of :"+dotSize);
              aShape = new Shape(dotSize, dotSize, 3*dotSize, 6*dotSize, Color.blue);
              this.addMouseListener(this);
              this.addMouseMotionListener(this);
         private void buildGUI() {
              setBackground(Color.white);
         public void paintComponent(Graphics g) {
              super.paintComponent(g);
              // custom paint code to 'draw dots'
              Rectangle r = g.getClipBounds();
              g.setColor(Color.gray);
              for(int x = 0;x<r.width;x=x+dotSize) {
                   for(int y=0;y<r.height;y=y+dotSize) {
                        g.drawLine(x, y, x, y);
              // draw out 'shape'
              g.setColor(aShape.c);
              g.fillRect(aShape.x, aShape.y, aShape.w, aShape.h);
         public void mousePressed(MouseEvent e) {
              Rectangle r = aShape.getRectangle();
              if (r.contains(e.getX(), e.getY())) {
                   inDrag = true;
                   xOffset = e.getX() - aShape.x;
                   yOffset = e.getY() - aShape.y;
         public void mouseReleased(MouseEvent e) {
              if (inDrag == true) {
                   inDrag = false;
         public void mouseClicked(MouseEvent e) {
         public void mouseEntered(MouseEvent e) {
         public void mouseExited(MouseEvent e) {
         public void mouseMoved(MouseEvent e) {
         public void mouseDragged(MouseEvent e) {
              if (inDrag == true) {
                   // check to see if the current mouse location falls on a 'dot' location
                   // the '%' or 'modulo' operator returns the remainder of a division.
                   // if the remainder is 'zero' then the point lies on a 'dot' or 'grid' location.
                   int x = (e.getX() - xOffset) % dotSize;
                   int y = (e.getY() - yOffset) % dotSize;
                   if (x == 0)
                        aShape.x = e.getX() - xOffset;
                   if (y == 0) {
                        aShape.y = e.getY() - yOffset;
                        c = true;
                   // cause the component to 'update' it's display
                   repaint();
         // inner class....just to give us something to 'drag around' the grid
         class Shape {
              int x, y, w, h;
              Color c;
              public Shape(int x, int y, int w, int h, Color c) {
                   this.x = x;
                   this.y = y;
                   this.w = w;
                   this.h = h;
                   this.c = c;
              public Rectangle getRectangle() {
                   return new Rectangle(x, y, w, h);
    }

  • How to implement 'hypelink' in ALV GRID

    Hi,everybody,please tell me how to implement 'hypelink' in ALV GRID?
    I just try to design a ALV GRID report but I do not kown the way of using 'hypelink'.  I refer to some documents but failsed.     somebody can help me and give a example including entire code.

    1. Create a table where hyperlinks & corresponding handles are stored (TYpe LVC_T_HYPE)
    DATA ls_hype TYPE lvc_s_hype .
    data lt_hype type lvc_t_hype.
    ls_hype-handle = '1' .
    ls_hype-href = 'http://www.company.com/carrids/car1' .
    APPEND ls_hype TO lt_hype .
    2. In your list data table create additional field of type INT4 which will contain the handle of the hyper link (ex. '1' for above hyperlink)
    DATA carrid_handle TYPE int4 .
    3. For the field which shall contain the hyperlink, make an entry in the field catalog indicating the field name which contains handle for the hyperlink. This is done by setting the handle field name in WEB_FIELD.
    ls_fieldcat-fieldname = 'CARRID'
    ls_fieldcat-web_field = 'CARRID_HANDLE'.
    4. While calling set_table_for_first_display, pass the hyperlink table created in step 1 to parameter 'it_hyperlink'
    ~Piyush Patil

  • How to make my own grid and perform a "snap to grid" effect?

    Hi! I am a newbie in flash and I am trying to create a puzzle like game (a chinese puzzle game called tangram). I am wondering what kind of functions should I use to create a "triangular" grid i.e. something similar to this ? http://img40.imageshack.us/img40/2259/triangulargrid.jpg. What should I do to make the movie clips to perform the "snap to grid" effect to this grid?I have tried to draw my own grid and used the "cacheAsBitmap" function to implent it, however it doesnt seems to be working. Is there any suggestions or tutorials to this problem? Thank you very much.

    Well, the project you are taking is not a simple one. It requires quite an experience with AS3. It is not a few lines of code but an understanding of Flash display list model and how objects can interact. In addition, there is no a single solution but rather wide array of possible approaches depending on use case.
    To illustrate, the code below draws a mesh that replicates the image in your first post. Do you think that this is enough from the standpoint of your AS3 knowledge to get you started?
    This code needs Flash 10:
    var side:Number = 400;
    var s:Sprite = new Sprite();
    var g:Graphics = s.graphics;
    g.lineStyle(3);
    //g.beginFill(0xFF8000);
    g.drawTriangles(
         Vector.<Number>([     0, 0, side * .5, 0, side, 0,
         side * .25, side * .25, side * .75, side * .25,
         0, side * .5, side * .5, side * .5, side, side * .5,
         side * .25, side * .75, side * .75, side * .75,
         0, side, side * .5, side, side, side
         Vector.<int>([
              0, 1, 3,
              1, 2, 4,
              0, 3, 5,
              1, 3, 6,
              5, 3, 6,
              1, 2, 4,
              1, 4, 6,
              2, 4, 7,
              6, 4, 7,
              5, 6, 8,
              5, 8, 10,
              6, 8, 11,
              10, 8, 11,
              6, 7, 9,
              6, 9, 11,
              7, 9, 12,
              9, 11, 12
    addChild(s);

  • How to snap to grid in Keynote 6?

    How do I enable snap to grid in Keynote 6.0?
    From the Keynote 09 manual (the most recent manual I could find):
    To turn on master gridlines:
    1 Choose Keynote > Preferences, and then click Rulers.
    2 Select either or both of the horizontal and vertical Master Gridlines checkboxes.
    (...etc) The check boxes mentioned under step 2 are no longer there. How does this work now?
    -Ron.

    Thanks, but I see no grid option or equivalent. I see a way to align objects to each other, and to some manually placed guides, but no grid.
    In Keynote '09, I had set up the grid at 10 pixel increments. I deliberately did not align objects to each other, because there are so many objects on a slide, some of which may be off-grid. This grid setting seems to have been lost when upgrading from '09 to 6.0, and I must now rely on more accurate eye-hand coordination.
    -Ron.

  • How to make every folder in finder snap to grid

    Hi, does anyone know how to make every folder in finder snap to grid? Without having to go one by one into the view options?
    Thanks!

    Open a folder, CMD+J, set it up as you want it, and click on the Use as Defaults button. That will set it for all unopened folders. For those previously opened and having other settings, you'll have to reapply it to each.

  • How to snap to grid lines in Logic Pro 9?

    In Garageband there's an option to "snap to grid lines" which means that when you click on the grid it will automatically snap the playhead to one of the lines, so it's always on a perfects beat. Does this option exist in Logic Pro 9? How do I turn it on? Thanks!

    Left Click and Hold on the Ruler Bar and then move your pointer left or right and it will snap to the Bar
    Or.. even simpler is to use the comma and period keys on your keyboard to move the playhead forwards and backwards by exactly one bar, snapping to the bar.

  • How do you disable snap to grid?

    This featured was listed as being added with the update to version 1.4, but I cannot find how to turn it off.  I have looked all through the app, and the separate Settings app, but I haven't been able to find the option anywhere or any updated documentation that describes where the option is.  Does anyone know where it is; maybe I am overlooking something obvious.  Thanks.

    This is the label that will be displayed in the TImeline once you are zoomed in all the way to indicate the new snap status. BTW affects also the manually moving of the Playhead.
    This is the article on Apple's website that explains the details
    http://support.apple.com/kb/HT5670?viewlocale=en_US&locale=en_US
    To turn off "Snap to Grid," pinch-zoom to the maximum level in Tracks view or when editing notes in regions. Pinch-zoom again and "Snap to Grid off" will appear on top of the Tracks area.To turn "Snap to Grid" back on, pinch-zoom out.
    Hope that helps
    Edgar Rothermich
    http://DingDingMusic.com/Manuals
    'I may receive some form of compensation, financial or otherwise, from my recommendation or link.'

  • How do you remove snap to grid in Garageband 10.0.2? I can't find it anywhere.

    Basically in older versions of Garageband, there used to be a setting under Control >> Snap to Grid and you could toggle it on and off. In this new version, I found that a lot of different, basic things that I knew how to do are no longer there, or are way harder to do. Snap to grid is one of those things, and I can't find it anywhere. Does anyone know how to turn off snap to grid?

    Choose Edit > Snap to Grid from the "Edit" menu.
    The "Snap to grid" option is not always visible. I am seeing it only, when a software instrument track is selected, the track editor window is open for that track, and  a region in the track is selected.

  • How do you turn off snap to grid in Logic Pro x

    Hi
    How do you turn off snap to grid as in garageband .....it was quite simple...
    But I don't seem to get to grips with this in logic ....
    I have options of smart ...and so on ....
    I want to be able to move eg an imported audio file to start wherever I want so not to snap to the nearest beat or bar...
    Anyone know??
    Thanks

    Technically you cannot turn it off, but you can choose a very fine resolution which in effect boils down to having it off: ticks. For accurately lining up audio you can use Samples (the smallest snap value, probably equates to GB's off setting?).
    I have F5 to F8 assigned to snap values bar, beat, division and tick. Very handy.
    The Frames values obviously come in handy when working to video, though there's no law agaist using it without video.
    Note that they are ordered from big to smallest.

  • How do I get icons to snap to grid?

    how do I get icons to snap to grid?

    Hi, is this on a Mac?
    One the Desktop or in a Finder Window, highlight one icon then select all, then choose Finder>View>Show View options.

  • How to disable folders snapping to grid on desktop

    I want to disable snap to grid of all folders, icons, jpegs, etc. on desktop. What I want is ability to move stuff around randomly.

    Right click on the desktop and click on Show view options and deselect snap to a grid.

Maybe you are looking for