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 get an event / change when text / item changes.
QtWS25 Last Chance

How to get an event / change when text / item changes.

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 924 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
    Anonymous_Banned275
    wrote on last edited by
    #1

    this is a repost of very old question which then never got resolved .
    I like to get another run at it , before i embark on anther wild goose chase.

    The original question is now little modified - due to some (gained) experience :

    I have a (item /text/line) widgets whose lines are being filled by external process. Attached.
    My task is to copy / transfer each (item / text /line ) to similar widget.
    ( This is not stupid way , just test of concept)
    I have found at lest two distinct widgets to do this , one uses text and the other item. I can deal with that - no problem and that is i NOT my question.

    The original and same question is
    there is no user interaction with the text / item being added ( by attached function) to these widgets. NONE - no mouse , keyboard . laser pointer - nothing !
    so are these identified as "current text / item " or "changed text / item " .

    It seem that each widget has different point of view as far as "generic change ".

    That is OK, but point of (MY) concern - "current " seems to be reserved when text / item is actually physically selected / highlighted - which is NOT my case.

    I realize this is little convoluted , but the key is - the text/ item appears in the widget and I need to detect that event , no matter what it is called.
    ( Yes , I did checked the docs)

    Here is a "test TRACE " generating function putting text / item to corresponding widgets

         qDebug() << Q_FUNC_INFO;
           ui->chat_3->setText(Q_FUNC_INFO);   // clear and addr QTextEdit 
           ui->listWidget->clear();                              // clear QListWidget 
          for ( int index = 0; index < 10; index++)
          {
             ui->chat_3->append(Q_FUNC_INFO ) ;  // text 
            ui->listWidget->addItem(Q_FUNC_INFO); //item 
          }
    
    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Since you add it to those widgets you can also emit a signal with the appended/new text there and do whatever you want with this.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      A 1 Reply Last reply
      2
      • Christian EhrlicherC Christian Ehrlicher

        Since you add it to those widgets you can also emit a signal with the appended/new text there and do whatever you want with this.

        A Offline
        A Offline
        Anonymous_Banned275
        wrote on last edited by Anonymous_Banned275
        #3

        @Christian-Ehrlicher OK if I can manage to display all available options to detect the event - I'll post it here so you can suggest the actual option .

        EDIT / ADD
        As I said - I am using two widgets to test. QTextWidget and QListWidget .
        Here are my similar "go to slot " functions .
        The QTextWidget responds as desired to "textChanged".
        The QListWidget DOES NOT generate "currentTextChanged" - I am assuming the "current" is when there is user interaction with the "item". I am not interested in that option, hence not verified.
        It seems that one has to be careful when QListWidget is used to monitor plain text , after all QListWidget handles "items" not text specifically.

        Unless there are more contributions I consider this closed - solved.

        // fill respose QTextWidget  TOK 
        void TabWidget_Chat::on_chat_3_textChanged()
        {
            qDebug() << Q_FUNC_INFO;
            int static index ;
            // fill response  trace
            // QString concatenate
            QString trace =Q_FUNC_INFO;
            trace.append("  index  # " + QString::number(index));
        //    ui->chat_3->append(trace ) ; // text
            ui->listWidget_2->addItem(trace); //
        
            index++;
        }
        
        
        // fill response QListWidget  not detected 
        void TabWidget_Chat::on_listWidget_currentTextChanged(const QString &currentText)
        {
            qDebug() << Q_FUNC_INFO;
            int static index ;
            // fill response  trace
            // QString concatenate
            QString trace = currentText ; //     Q_FUNC_INFO;
            trace.append("  index  # " + QString::number(index));
        //    ui->chat_3->append(trace ) ; // text
            ui->listWidget_2->addItem(trace); //
        
            index++;
        }
        
        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