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 set focus on QLineEdit while QTextEdit still active?

How to set focus on QLineEdit while QTextEdit still active?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.4k Views
  • 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.
  • A Offline
    A Offline
    Arrandale
    wrote on last edited by
    #1

    I want QLineEdit to be focus for editing while emit textChanged signal
    to QTextEdit for text selection.

    It's work fine after emit signal but I have to setFocus on QTextEdit
    to get active selected text and now QLineEdit has lost focus
    to editing cause the focus is on QTextEdit.

    How to set QTextEdit just for active selected text without lost focus from QLineEdit?

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      You don't need to mess with focus of QTextEdit. It's just that by default color of highlight of inactive control is the same as unselected. Change it to be the same color as the active highlight and you're good to go:

      @
      auto p = textEdit->palette();
      p.setColor(QPalette::Inactive, QPalette::Highlight, p.color(QPalette::Active, QPalette::Highlight));
      p.setColor(QPalette::Inactive, QPalette::HighlightedText, p.color(QPalette::Active, QPalette::HighlightedText));
      textEdit->setPalette(p);
      @

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Arrandale
        wrote on last edited by
        #3

        Oh. I never think in this way. lol
        Thanks.

        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