How to get closeevent signal from a qtable view?



  • Actually, i'm creating a qtableview instance within mainwindow class, so now i want to catch the closeevent signal from that instance.
    how can i achieve this?
    please any one can tell me the approach.



  • @moyin
    If QTableView is child off MainWindow, why do you need closeEvent qtableView ? Is not it better MainWindow closeEvent? Do you see any problem?



  • closeEvent is not a signal.
    You have to subclass QTableView and implement such a signal:

    class MyTableView : public QTableView {
    Q_OBJECT
    Q_DISABLE_COPY(MyTableView)
    public:
    MyTableView(QWidget* parent = Q_NULLPTR) : QTableView(parent){}
    Q_SIGNAL void closeSignal();
    protected:
    void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE{
    closeSignal();
    QTableView::closeEvent(event);
    }
    };


  • @VRonin
    i tried to nest this class i'm getting this below error,
    error : meta object features not supported for nested classes


  • Moderators

    @moyin said in How to get closeevent signal from a qtable view?:

    i tried to nest this class

    Why?
    You need to subcalss not nest.


Log in to reply
 

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