Results 1 to 3 of 3

Thread: how can i write common slot for buttons

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2011
    Posts
    81
    Thanks
    8
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default how can i write common slot for buttons

    i have 121buttons on a gridlayout. On button click i have to connect to a slot.(common to all 121buttons). This worked for me when i used connect function in a for loop.

    Qt Code:
    1. for(i=0;i<121;i++)
    2. connect(buttons[i],SIGNAL(clicked()),this,SLOT(drawline()));
    To copy to clipboard, switch view to plain text mode 


    But i need the button no in the slot "drawline", I mean in drawline i have to get an integer value. between 1 to 121 corresponding to the button clicked.

    I tryed
    Qt Code:
    1. for(i=0;i<121;i++)
    2. connect(buttons[i],SIGNAL(clicked()),this,SLOT(drawline(i)));
    To copy to clipboard, switch view to plain text mode 

    but doesnot worked

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how can i write common slot for buttons

    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    athulms (29th September 2011)

  4. #3
    Join Date
    Jul 2011
    Posts
    81
    Thanks
    8
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default Re: how can i write common slot for buttons

    it worked

Similar Threads

  1. Common buttons on a stacked widget
    By premroxx in forum Newbie
    Replies: 4
    Last Post: 15th November 2013, 23:02
  2. Replies: 5
    Last Post: 14th September 2010, 21:13
  3. Replies: 2
    Last Post: 12th June 2010, 02:21
  4. Q_PROPERTY WRITE function, also a slot?
    By Eos Pengwern in forum Newbie
    Replies: 2
    Last Post: 12th December 2009, 21:29
  5. Common slot on some widgets [Qt3]
    By Opilki_Inside in forum Newbie
    Replies: 4
    Last Post: 27th March 2006, 14:26

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.