Results 1 to 2 of 2

Thread: Button Grouping for generic functions

  1. #1
    Join Date
    Dec 2010
    Posts
    23
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Windows

    Default Button Grouping for generic functions

    I am trying to create a class or some sort of setup that groups several groups buttons so that I can create one function that will apply to all the groups. Then I can hopefully use a this call to change the other buttons in the class and/or grouping.

    For example, say I have a setup of 3 buttons, for example Start, Add, and Subtract. I want to set up several instances of this three button grouping on one main window, say 5 instances. Each instance starts with the Add and Subtract buttons not enabled. I want a way to create one function start() which will be called when any one of the start buttons is pushed, and the function will enable the Add and Subtract button in that grouping and disable the start button that is clicked.

    The only way I know how to do it now is to create 5 different functions, one for each instance of the three buttons, which has basically the same code but with each of the different functions referring to a different set of buttons.


    So how can I create a grouping so that I only need one function to handle all of the groupings (my actual program has more than 5 instances with several functions for each instance, so figuring out this general procedure will significantly decrease the amount and cleanliness of my code).

    Thank you in advance.

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

    Default Re: Button Grouping for generic functions

    Create a custom widget composed of your three buttons and add a start() slot to the widget that will change the enabled state of the buttons in the widget. Also add two or three signals emitted when a particular button in the group is clicked.
    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.


Similar Threads

  1. how to make one button to do two functions
    By Shien in forum Qt Programming
    Replies: 1
    Last Post: 2nd January 2011, 20:18
  2. Dynamic Grouping of QTableView Rows
    By stefanadelbert in forum Qt Programming
    Replies: 5
    Last Post: 7th December 2010, 06:15
  3. Generic-enough QAbstractItemModel.
    By hickscorp in forum Qt Programming
    Replies: 0
    Last Post: 5th November 2010, 04:55
  4. Grouping files
    By Jeffb in forum Newbie
    Replies: 4
    Last Post: 15th June 2010, 10:29
  5. Grouping Widgets Together
    By joshuajcarson in forum Qt Programming
    Replies: 1
    Last Post: 21st October 2008, 20:17

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.