Results 1 to 3 of 3

Thread: Row and Coloum Position

  1. #1
    Join Date
    May 2011
    Posts
    21
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Symbian S60

    Default Row and Coloum Position

    hello friends

    Actually i have created an Array of buttons in 6 X 7 matrix..now if on each click of the button i want to know the positons of row and colums of that particular buttons that i have clicked than how it can be done…please suggest me..

    regards
    Rahul

  2. #2
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Row and Coloum Position

    Ask whatever QLayout you used.

    Or embed the information in each button.

    Or calculate it based on the pixel size of the array and what's known about the geometry of the buttons.

  3. #3
    Join Date
    Oct 2009
    Posts
    483
    Thanked 97 Times in 94 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Row and Coloum Position

    When you connect several signals to the same slot and you need to know in the slot which signal was emitted, you can use QSignalMapper. Basically it allows you to add an argument to the slot, of type int, QString, QWidget* or QObject*) to help you identify the emitter.

    In your case I can suggest two options:

    - embed the information in each button like SixDegrees suggested (e.g. by deriving QPushButton and declaring and initializing appropriate fields) and map each button to a pointer to itself (QWidget*) in the QSignalMapper; that way you get back the pointer in the slot and can read the information from the object.

    - do not bother deriving QPushButton and map each button to an integer identifying it; for example, if i, j are the coordinates of a button (i in 0..5 and j in 0..6), map the button to the integer i * 7 + j; you can then use / and % to recover i and j from the integer in the slot.

Similar Threads

  1. Get GPS Position with QML
    By jgaleanog in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 4th August 2011, 11:41
  2. To Set the Position of the dialog
    By merry in forum Qt Programming
    Replies: 3
    Last Post: 21st December 2007, 21:35
  3. QTextCursor position
    By high_flyer in forum Qt Programming
    Replies: 3
    Last Post: 10th December 2007, 09:17
  4. Button position
    By Mrdata in forum Newbie
    Replies: 1
    Last Post: 26th February 2007, 16:58
  5. set Position
    By mickey in forum Newbie
    Replies: 3
    Last Post: 17th June 2006, 21:30

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.