can hide widget emit signal



  • Hi everybody,

    is it possible to emit a signal from an hidden widget? According to my tests, this does not seems to be allowed.

    Many thanks
    Andrea



  • @Andrea hiho,
    I'm afraid your testing went wrong somewhere, hiding a widget has no effect on it's signals. Accept of course GUI-interact signals, mouseclicks, butten clicks etc. You can't interact with stuff thats not there. But everything else e.g QTimer::timeout signals work just fine.



  • @J-Hilk many thanks for your reply. In my question I'm not been clear enough.
    I've a button that allows the user to "go back to previous window" of my embedded application and, in some windows, this button has to be hidden.
    Now, what I would like to achieve is to emit the "click" signal of the button even if it is hidden, not by clicking on it from GUI, but by code, calling instruction

    emit myButton->click();
    

    When I do so, since the button (or any other widgets) is not shown, I'm unable to recall its 'click' signal, and this is a behaviour that has sense to me.



  • @Andrea
    What you describe is still possible take this example:

    QPushButton *myButton = new QPushButton();
    connect(myButton, &QPushButton::clicked, this, [=]{qDebug() << "PushButton Clicked signal";});
    
    myButton->hide();
    
    myButton->clicked();
    

    You'll see PushButton Clicked signal in your consol log.

    edit:
    There is also nothing preventing you to call the SLOT, your button connects to, manualy.


  • Lifetime Qt Champion

    Hi,

    Out of curiosity, why do you want to "simulate" a button click ?



  • This post is deleted!

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.