Frage

I have an object that inherits from QTextEdit, which looks like this:

class infoBox : public QTextEdit
{
    Q_OBJECT

public:
    :
    :
}

I use it in my UI window like this:

class Ui_MainWindow
{
    infoBox *pInfoBox;

public:

    void setupUi(QMainWindow *MainWindow)
    {
        pInfoBox = new infoBox(MainWindow);
        pInfoBox.show();
    }
}

This is a really cut-down version of my code just to show you how its setup. What happens is my MainWindow opens with the infoBox inside it (infoBox settings are in the c'tor), so far so good.

Now I want to make it work a bit like a splash-screen such that when I click it it goes away (i.e. call the code pInfoBox.hide(). But I can't see a signal "onclick" or any such thing for the QTextEdit so I can't connect a signal/slot to do this. How can I achieve this?

War es hilfreich?

Lösung

For example, you can handle click event (mouse release) in your infoBox class:

class infoBox : public QTextEdit
{
    Q_OBJECT

    [..]

protected:
    void mouseReleaseEvent(QMouseEvent *event)
    {
        hide();
    }
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top