Results 1 to 11 of 11

Thread: QomboBox - activated(), highlighted()

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Netherlands
    Posts
    56
    Qt products
    Qt3 Qt4
    Platforms
    Windows
    Thanks
    10
    Thanked 2 Times in 2 Posts

    Default Re: QomboBox - activated(), highlighted()

    I think u can best use the clicked() signal from the OK button and connect that signal to a slot you have created.... when arriving in that slot, ask the text that is present at your combobox and check it against your "number 1".

    Thats my opinion how i should do it..
    ..:: Still Standing Strong ::..

  2. #2
    Join Date
    May 2007
    Posts
    315
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Default Re: QomboBox - activated(), highlighted()

    Quote Originally Posted by BrainB0ne View Post
    I think u can best use the clicked() signal from the OK button and connect that signal to a slot you have created
    That's what I've done And about this slot, how can I compare text with "number one"? As you've seen in the code that Designer generated, there's no thing such as number1 or item1, so how would the comparision look like? (in code, as well)

  3. #3
    Join Date
    May 2007
    Posts
    315
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Default Re: QomboBox - activated(), highlighted()

    Does anyone know?

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    21
    Thanked 418 Times in 411 Posts

    Default Re: QomboBox - activated(), highlighted()

    use QComboBox::activated()
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. #5
    Join Date
    May 2007
    Posts
    315
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Default Re: QomboBox - activated(), highlighted()

    But it is important which 'line' was chosen

  6. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    21
    Thanked 418 Times in 411 Posts

    Default Re: QomboBox - activated(), highlighted()

    Wnat do you mean?
    Could you explain more what the problem is?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  7. #7
    Join Date
    Jan 2006
    Location
    Netherlands
    Posts
    56
    Qt products
    Qt3 Qt4
    Platforms
    Windows
    Thanks
    10
    Thanked 2 Times in 2 Posts

    Default Re: QomboBox - activated(), highlighted()

    Quote Originally Posted by Salazaar View Post
    That's what I've done And about this slot, how can I compare text with "number one"? As you've seen in the code that Designer generated, there's no thing such as number1 or item1, so how would the comparision look like? (in code, as well)
    well, we have two functions here:

    int QComboBox::currentItem () const
    Returns the index of the current item in the combobox. See the "currentItem" property for details.

    QString QComboBox::currentText () const
    Returns the text of the combobox's current item. See the "currentText" property for details.

    I assume you know the contents of the combobox, you can use an if statement like:
    Qt Code:
    1. if(yourComboBox->currentText() == "YourTextAtItemNumber1")
    2. {
    3. // open your dialog.....
    4. }
    To copy to clipboard, switch view to plain text mode 

    or

    Qt Code:
    1. if(yourComboBox->currentItem() == 1)
    2. {
    3. // open your dialog.....
    4. }
    To copy to clipboard, switch view to plain text mode 
    ..:: Still Standing Strong ::..

  8. #8
    Join Date
    May 2007
    Posts
    315
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Default Re: QomboBox - activated(), highlighted()

    Thanks that's the answer I was looking for

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.