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. Synchronize 2 QlineEdit
Forum Update on Monday, May 27th 2025

Synchronize 2 QlineEdit

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 987 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.
  • M Offline
    M Offline
    Mattia
    wrote on last edited by
    #1

    Dear all, I have a window with some QlineEdit fields and I would like to synchronize 2 of them so that when I change the text in one, also the other is updated. For the moment I have solved the problem creating a slot textChanged () for each of the 2 fields and inside putting a setText () to the other field. Is there some other implementation that gives the same result but without having to modify both slots?

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

      Hi
      You can directly connect
      Edit1
      QLineEdit::textChanged(const QString &text)
      to Edit2
      void setText(const QString &)
      and reverse
      Then typing in one will type same in other.

      1 Reply Last reply
      2
      • M Offline
        M Offline
        Mattia
        wrote on last edited by
        #3

        Yes, this is exactly what I am doing. I just wanted to know is there is a smarter way to synchronise two or more fields.

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

          Ok, i read it like you implemented a slot to set text and not directly used
          2 connects. (with no slot implementation). that is the most compact way.

          There is also
          http://doc.qt.io/qt-5/qdatawidgetmapper.html#details
          Which makes it easy to share a model with multiple widgets.

          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