Results 1 to 9 of 9

Thread: Drop down menu in qt4?

  1. #1
    Join Date
    Aug 2008
    Posts
    52
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Drop down menu in qt4?

    Hi all,

    I have a lineEdit widget and I am trying to make a drop down menu similar to the one that firefox has on the top right(where google search is).

    In qt3 I found a class QPopupMenu. But this class is not included in qt4. Is there anything similar for qt4?

    Can you please provide a sample code to demonstrate that?

    Many thanks in advance.

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Drop down menu in qt4?

    I think this hepls you QToolButton

  3. #3
    Join Date
    Aug 2008
    Posts
    52
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Drop down menu in qt4?

    Thank you for the reply.

    What i actually want is to pop up a menu containing the results of a query made from the text box.Very similar to what firefox does in the top right box

  4. #4
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Drop down menu in qt4?

    so, you need to show popup when you input data in QLineEdit, right?

  5. #5
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Drop down menu in qt4?

    see this calss QCompleter

  6. The following user says thank you to spirit for this useful post:

    cbarmpar (25th September 2008)

  7. #6
    Join Date
    Aug 2008
    Posts
    52
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Drop down menu in qt4?

    I have one more question.

    If i want to add a custome message in this pop up box say for example:
    "possible matches":
    and then the matches found how can i do that?

    Because with completer a pop up window shows only with the completion options.

    regards.

  8. #7
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Drop down menu in qt4?

    m... I'm not sure that I understand what you mean.

  9. #8
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Drop down menu in qt4?

    a bit of a hack:

    Set QCompleter::setPopup with a QTreeView and have the model provide your "text"
    in its headerData() function as caption of the first column.

    (Haven't tried it. Please post if it works.)

  10. #9
    Join Date
    Aug 2008
    Posts
    52
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Drop down menu in qt4?

    caduel thats a good idea.

    I will try it now.

    But even if that works it doesnt give you the flexibility that i would like.
    What about if i would like to provide more than one custom message apart from the completion options. For example, I want my cutom message in the first line then have some completion options and then another custom message in the fifth line. This is not possible with the header technique that you suggesting I think.

    I will try it and let you know.
    Regards
    Last edited by cbarmpar; 26th September 2008 at 14:21. Reason: reformatted to look better

Similar Threads

  1. Docked Widget Menu
    By Chuk in forum Qt Programming
    Replies: 6
    Last Post: 3rd July 2013, 14:12
  2. Replies: 2
    Last Post: 27th June 2008, 19:02
  3. MainWindow Menu bug in Qt 4.2.3?
    By No-Nonsense in forum Qt Programming
    Replies: 4
    Last Post: 11th March 2007, 11:47
  4. Drag and drop revisited
    By Big Duck in forum Newbie
    Replies: 2
    Last Post: 30th June 2006, 16:41
  5. Tracking separators in a menu (insertSeparator)
    By PrimeCP in forum Qt Programming
    Replies: 4
    Last Post: 25th January 2006, 18:10

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.