Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to create a menu with focusable items instead of QActions
Forum Updated to NodeBB v4.3 + New Features

How to create a menu with focusable items instead of QActions

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 278 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    oguzhankartal
    wrote on last edited by
    #1

    Hello everyone,

    I am developing a GUI for a project that has a touch screen and rotary encoder. I need to create a dropdown menu that will be used as a "Settings Menu," and it will have buttons such as Brightness, Sound, etc., that are accessible with the use of a rotary encoder. Everything works very well with a touch screen, but this menu should also be usable with a rotary encoder for the sake of my project.

    My problem is, I could only create a menu with actions, and these actions are not "buttons," so that they are not focusable. To use this menu with a rotary encoder, items of this menu should be focusable and clickable. Is there a way to do this? I also want to indicate that I have two classes, "Screens," in the MainWindow. This "Settings" menu should be usable on both screens. The best way for me to add QPushButtons to the dropdown menu created by another QPushButton.

    Thank you in advance; I am open to all comments about this topic.

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      Hi
      Try to use
      https://doc.qt.io/qt-5/qwidgetaction.html
      it should allow anything in the QMenu.

      alt text

      1 Reply Last reply
      4
      • O Offline
        O Offline
        oguzhankartal
        wrote on last edited by
        #3

        Hello, thanks for your help.

        I am a beginner in Qt; I looked at the class definition of your example but couldn't make it work for my purpose. Can you give an example of how to set focus property and add buttons to the menu using QWidgetAction.

        Thank you in advance.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved