Results 1 to 5 of 5

Thread: Creating events for combobox items

  1. #1
    Join Date
    Mar 2006
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Creating events for combobox items

    hey every1 this is my first post so im not sure if any1 will reply but here it goes. i have created a QCombobox and i have added 3 items to it. for each item i want it to signal a seperate event. is it possible to do this or should i use some other widget. i tried using highlighted() and activated() but they only seem to work for the combobox as a whole, is there anything i could use?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 975 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Creating events for combobox items

    Both of these signals carry the item index:
    void QComboBox::activated ( int index ) [signal]
    This signal is sent when an item in the combobox is activated by the user. The item's index is given.

  3. #3
    Join Date
    Mar 2006
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Creating events for combobox items

    I tried the function with the following piece of code:

    Qt Code:
    1. connect(comboBox1, SIGNAL(activated(int 1)), this, SLOT(item1Chosen()));
    To copy to clipboard, switch view to plain text mode 

    but the debug says there is no such signal? do i have to set up the item's index manually?how would i go about doing that?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 975 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Creating events for combobox items

    Quote Originally Posted by confused
    but the debug says there is no such signal?
    Because you can't put parameter values in SIGNAL or SLOT macros.

    Try this:
    Qt Code:
    1. connect( comboBox1, SIGNAL( activated( int ) ),
    2. this, SLOT( itemChosen( int ) ) );
    To copy to clipboard, switch view to plain text mode 

  5. The following user says thank you to jacek for this useful post:

    confused (26th March 2006)

  6. #5
    Join Date
    Mar 2006
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Creating events for combobox items

    ok yeah i understand what ur trying to say now - i figured it out. thanks for the help

Similar Threads

  1. QGraphicsView Mouse Events
    By tomf in forum Qt Programming
    Replies: 5
    Last Post: 29th July 2008, 16:03
  2. MousePress Events on ContextMenu items
    By Naveen in forum Qt Programming
    Replies: 1
    Last Post: 22nd February 2006, 08: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.