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. QEvent not triggered
Qt 6.11 is out! See what's new in the release blog

QEvent not triggered

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

    I want to listen focus in/out events of qlineedit on my ui. I tried eventfilter:

    bool MainWidget::eventFilter(QObject* object, QEvent* event)
    {
        if(object == ui->lineEditTop && event->type() == QEvent::FocusIn) {
            qDebug() << "IN";
            return false;
        }
        if(object == ui->lineEditTop && event->type() == QEvent::FocusOut) {
            qDebug() << "OUT";
            return false;
        }
        return false;
    }
    

    on constructor:

    setFocusPolicy(Qt::StrongFocus);
    installEventFilter(this);
    

    In this way if blocks never executed. If i remove object == ui->lineEditTop from condition, if blocks runs when i am clicking ui except lineedit. Any idea what is wrong with code?

    1 Reply Last reply
    0
    • B Offline
      B Offline
      Bonnie
      wrote on last edited by
      #2
      ui->lineEditTop->installEventFilter(this);
      
      M 1 Reply Last reply
      2
      • B Bonnie
        ui->lineEditTop->installEventFilter(this);
        
        M Offline
        M Offline
        masa4
        wrote on last edited by
        #3

        @Bonnie said in QEvent not triggered:

        ui->lineEditTop->installEventFilter(this);

        Hey man you are the life saver. thank you very much:) I was searching this for several days.

        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