Page 1 of 1

Update a table when user switches between opened tabs

Posted: Tue Apr 15, 2014 7:45 pm
by s4eed
Hi everyone.
I created a program based on the QCad Application framework that has a QTableWidget in a QDockWidget. I need to update contents of this table when user switches between opened files in the application. How can I be informed that user has selected a new tab in MDI area?

Re: Update a table when user switches between opened tabs

Posted: Tue Apr 15, 2014 7:56 pm
by andrew
Creating a focus listener class:
function MyFocusListener() {
    RFocusListenerAdapter.call(this);
}

MyFocusListener.prototype = new RFocusListenerAdapter();

MyFocusListener.prototype.updateFocus = function(documentInterface) {
    // this will be called whenever the user switched to another document
    // documentInterface may be undefined if no document is open (last document was closed)
    // in this case, a widget is typically cleared
};
Installing the focus listener:
var appWin = EAction.getMainWindow();
var fl = new MyFocusListener();
appWin.addFocusListener(fl);

Re: Update a table when user switches between opened tabs

Posted: Sun Apr 20, 2014 11:30 am
by s4eed
Thanks but I got this error :

Code: Select all

RMainWindow: Argument 0 is not of type RViewFocusListener *RViewFocusListener *.

Re: Update a table when user switches between opened tabs

Posted: Sun Apr 20, 2014 12:05 pm
by andrew
Sorry, the last line should be:
appWin.addFocusListener(fl);
(I've also corrected this in the previous post to avoid confusion for other readers).