Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Manually calling lineEdit's textChanged
Forum Updated to NodeBB v4.3 + New Features

Manually calling lineEdit's textChanged

Scheduled Pinned Locked Moved Mobile and Embedded
5 Posts 2 Posters 2.6k 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.
  • R Offline
    R Offline
    root
    wrote on last edited by
    #1

    How to force call of lineEdit's textChanged at startup?
    The workaround is:
    @MainWindow::MainWindow(QWidget *parent) :
    ...
    QString s = ui->vectorEdit->text()+" ";
    ui->vectorEdit->setText(s);@

    How to do it properly? And without adding a space.

    1 Reply Last reply
    0
    • JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      -You can subclass the QLineEdit and make it emit the signal in its constructor-

      Edit: Sorry, I just realized you can't emit signals in a constructor, because you don't have time to connect it to a slot first!

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      0
      • R Offline
        R Offline
        root
        wrote on last edited by
        #3

        And how to use such subclasses in Designer? If there is no way of inheritance?

        1 Reply Last reply
        0
        • JKSHJ Offline
          JKSHJ Offline
          JKSH
          Moderators
          wrote on last edited by
          #4

          You can "promote" your custom widget to use it in Designer (see http://qt-project.org/doc/qt-4.8/designer-using-custom-widgets.html#promoting-widgets ). You can't see it in Designer though; there will be a blank space.

          Without using inheritance, you can create a signal in your QMainWindow, connect that signal to QLineEdit::textChanged(), and make your QMainWindow emit that signal.

          @
          MainWindow : public QMainWindow
          {
          ...
          signals:
          void started(QString);

          public:
          MainWindow(QWidget *parent) : QWidget(parent)
          {
          connect(this, SIGNAL(started(QString)),
          ui->vectorEdit, SIGNAL(textChanged(QString)));

              emit started(ui->vectorEdit->text());
          }
          

          };
          @

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          1 Reply Last reply
          0
          • JKSHJ Offline
            JKSHJ Offline
            JKSH
            Moderators
            wrote on last edited by
            #5

            Sorry, I just realized you can’t emit signals in a constructor, because you don’t have time to connect it to a slot first!

            Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

            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