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 setFocus on two widgets at once
Qt 6.11 is out! See what's new in the release blog

How to setFocus on two widgets at once

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 820 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.
  • L Offline
    L Offline
    lantern
    wrote on last edited by
    #1

    I need to have a widget exactly like Sublime Text menus, like the package control / theme menu.

    The QLineEdit can always be typed in and the list can always be scrolled as long as their parent widget is active. Is this possible in Qt?

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

      well if u set list to Nofocus you can scroll it with mouse and keyboard focus stays with
      QLineEdit

      1 Reply Last reply
      3
      • L Offline
        L Offline
        lantern
        wrote on last edited by lantern
        #3

        Well its not ideal but I got it working.

        • ListView has noFocus policy.
        • If line edit has focus, re-implemented up and down arrows keys change index and selection of listview.
        • Line Edit change policy to clickFocus because otherwise the arrows keys cause it to get focus (undesirable).
        • connect ListView row clicked to accept and close events even if the menu wasnt focused.
        • Style listview selected:!active so it doesnt show two different colors on click

        I will post the code soon, I also want to try the classical QListWidget, it might be way simpler and should be faster?

        1 Reply Last reply
        1

        • Login

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