Update a table when user switches between opened tabs

Discussion forum for contributors and developers who are using the QCAD version 3 ECMAScript development platform or the C++ plugin interface or who are otherwise looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Update a table when user switches between opened tabs

Postby s4eed » Tue Apr 15, 2014 7:45 pm

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?
s4eed
Junior Member
 
Posts: 18
Joined: Fri Sep 27, 2013 3:23 pm

Re: Update a table when user switches between opened tabs

Postby andrew » Tue Apr 15, 2014 7:56 pm

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);
User avatar
andrew
Site Admin
 
Posts: 2556
Joined: Fri Mar 30, 2007 6:07 am

Re: Update a table when user switches between opened tabs

Postby s4eed » Sun Apr 20, 2014 11:30 am

Thanks but I got this error :
Code: Select all
RMainWindow: Argument 0 is not of type RViewFocusListener *RViewFocusListener *.
s4eed
Junior Member
 
Posts: 18
Joined: Fri Sep 27, 2013 3:23 pm

Re: Update a table when user switches between opened tabs

Postby andrew » Sun Apr 20, 2014 12:05 pm

Sorry, the last line should be:

appWin.addFocusListener(fl);
(I've also corrected this in the previous post to avoid confusion for other readers).
User avatar
andrew
Site Admin
 
Posts: 2556
Joined: Fri Mar 30, 2007 6:07 am


Return to QCAD 3 Developers and Contributors

Who is online

Users browsing this forum: No registered users and 1 guest