Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |
The code demonstrates how the TQt application can communicate with the embedded ActiveX controls using signals, slots and the dynamicCall() function. Most signal and slot connections have already been set up within TQt Designer.
void MainWindow::init() { pb = new TQProgressBar( statusBar() ); pb->setPercentageVisible( FALSE ); pb->hide(); statusBar()->addWidget( pb, 0, TRUE ); connect( WebBrowser, SIGNAL(ProgressChange(int,int)), this, SLOT(setProgress(int,int)) ); connect( WebBrowser, SIGNAL(StatusTextChange(const TQString&)), statusBar(), SLOT(message(const TQString&)) ); WebBrowser->dynamicCall( "GoHome()" ); }The init() function is implemented to create a progress bar as the child of the status bar, and to connect Internet Explorer's ProgressChange() and StatusTextChange() signals to the respective displays.
Finally the GoHome() function of Internet Explorer is invoked using the TQAxBase::dynamicCall() dynamicCall() API.
void MainWindow::go() { actionStop->setEnabled( TRUE ); WebBrowser->dynamicCall( "Navigate(const TQString&)", addressEdit->text() ); }The go() function calls the NavigateTo() function of Internet Explorer, passing the text of the address bar as the argument.
void MainWindow::setTitle( const TQString &title ) { setCaption( "TQt WebBrowser - " + title ); }The setTitle() slot is connected to the TitleChange() signal of Internet Explorer, and updates the caption of the window using the provided title string.
void MainWindow::setProgress( int a, int b ) { if ( a <= 0 || b <= 0 ) { pb->hide(); return; } pb->show(); pb->setTotalSteps( b ); pb->setProgress( a ); } void MainWindow::setCommandState( int cmd, bool on ) { switch ( cmd ) { case 1: actionForward->setEnabled( on ); break; case 2: actionBack->setEnabled( on ); break; } } void MainWindow::navigateBegin() { actionStop->setEnabled( TRUE ); } void MainWindow::navigateComplete() { actionStop->setEnabled( FALSE ); }The setProgress(), setCommandState(), navigateBegin() and navigateComplete() slots are connected to the respective signals of Internet Explorer and update the user interface.
The rest of the implementation is not related to ActiveTQt and omitted for brevity.
To build the example you must first build the TQAxContainer library. Then run your make tool in examples/webbrowser and run the resulting webbrowser.exe.
See also The TQAxContainer Examples.
Copyright © 2007 Trolltech | Trademarks | TQt 3.3.8
|