Results 1 to 4 of 4

Thread: Combobox Signals

  1. #1
    Join Date
    Jun 2006
    Posts
    64
    Thanks
    10
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Combobox Signals

    G'Day All,

    I am fairly new to QT. I am using QT4.1.1 and I am having a problem with combobox signals.

    I have created a widget with a multiple lineedits and comboboxes. The comboboxes are prefilled by a function that calls data from a database. This part works fine. When I click on the combobox I can select any of the line items that have been entered.
    I have created a signal/slot to run a function that fills the remainder of the widgets based on the combobox selection.
    However, when I press tab, enter or click another lineedit/combobox, the highlighted item remians displayed, the focus moves, but the function does not get run. It appears the signal is not emmited. I have tried each of the following to avail.

    connect( comboBox_3, SIGNAL( currentIndexChanged() ), this, SLOT( readSData() ) );
    connect( comboBox_3, SIGNAL( highlighted() ), this, SLOT( readSData() ) );
    connect( comboBox_3, SIGNAL( returnPressed() ), this, SLOT( readSData() ) );


    The "readSData()" is declared as a slot and runs if called manually.

    The signal/slots used for the "lineedits" and "pushbuttons" all work correctly. It is only the "comboboxes" that don't work.

    Any thoughts or suggestions would be appreciated.

    Regards, rod

  2. #2
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Combobox Signals

    It should be

    Qt Code:
    1. connect( comboBox_3, SIGNAL( currentIndexChanged(int) ), this, SLOT( readSData() ) );
    2. connect( comboBox_3, SIGNAL( highlighted(int) ), this, SLOT( readSData() ) );
    To copy to clipboard, switch view to plain text mode 

    There is no signal called returnPressed that is emitted by QComboBox.

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Combobox Signals

    Quote Originally Posted by munna
    There is no signal called returnPressed that is emitted by QComboBox.
    You may, however, connect to combo box's internal line edit:
    Qt Code:
    1. connect( comboBox_3->lineEdit(), SIGNAL( returnPressed() ), this, SLOT( readSData() ) );
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  4. #4
    Join Date
    Jan 2006
    Location
    India
    Posts
    54
    Thanks
    1
    Thanked 7 Times in 6 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: Combobox Signals

    Have you defined th Q_OBJECT macro in your header file.

Similar Threads

  1. Filling combobox from database
    By Philip_Anselmo in forum Qt Programming
    Replies: 3
    Last Post: 11th May 2006, 17:53
  2. table with combobox cells
    By mgurbuz in forum Qt Programming
    Replies: 2
    Last Post: 10th May 2006, 12:12
  3. Signals and Slots in dll
    By ankurjain in forum Qt Programming
    Replies: 8
    Last Post: 29th March 2006, 08:12
  4. Problem with Signals and Slots
    By Kapil in forum Newbie
    Replies: 11
    Last Post: 15th February 2006, 11:35
  5. KDE Signals
    By chombium in forum KDE Forum
    Replies: 1
    Last Post: 25th January 2006, 18:45

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.