Update a table when user switches between opened tabs

Discussion forum for C++ and script developers who are using the QCAD development platform or who are looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files, scripts and screenshots.

Post one question per topic.

Post Reply
s4eed
Junior Member
Posts: 18
Joined: Fri Sep 27, 2013 3:23 pm

Update a table when user switches between opened tabs

Post by 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?

User avatar
andrew
Site Admin
Posts: 9037
Joined: Fri Mar 30, 2007 6:07 am

Re: Update a table when user switches between opened tabs

Post by 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);

s4eed
Junior Member
Posts: 18
Joined: Fri Sep 27, 2013 3:23 pm

Re: Update a table when user switches between opened tabs

Post by 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 *.

User avatar
andrew
Site Admin
Posts: 9037
Joined: Fri Mar 30, 2007 6:07 am

Re: Update a table when user switches between opened tabs

Post by 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).

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”