顯示具有 qt 標籤的文章。 顯示所有文章
顯示具有 qt 標籤的文章。 顯示所有文章
| 0 意見 ]

http://www.youtube.com/watch?v=FTOaBeKGBKQ





Qt designer webview, still need coding



Qt connect MySQL



| 0 意見 ]

http://www.thisisqt.com/forum/viewthread.php?tid=184&page=1&extra=#pid377



QWebView类提供了一个可以展现和编辑网页文档的widget。

QWebView是QtWebKit网页浏览模块的一个主要widget组件,可以用它来展现互联网网页。

下图展现了一个在Qt Designer中创建的一个QWebView,它展现的是诺基亚的官网:



可以使用QWebView的load()方法来加载一个网站,这里和其他的所有Qt的widget一样,你需要调用show()方法才会显示出QWebView。

如下例所示:

01. QWebView *view = new QWebView(parent);



02. view->load(QUrl("http://qt.nokia.com/"));



03. view->show();

复制代码另外setUrl()方法也可以用来加载一个网站,而如果你有现成的HTML文件,则可以直接调用setHtml()方法来加载。

当网页开始加载时会发出loadStarted()的信号,当网页中任何一个元素被加载完都会发出loadProgress()信号,例如一个图片,或是一段脚本。最后当网页全部加载完成后会发出loadFinished()信号,其中loadFinished()信号携带的参数会说明加载是否成功,如果参数为真则加载成功,否则加载失败。



page()方法返回一个指向QWebPage网页对象的指针,在下面我们会讲到QWebPage和QWebView之间的关系。

你可以通过QWebView的settings()方法获得QWebSettings对象,进而可以对网页做相关设置,比如修改默认的字体,开启或禁止JavaScript和插件等。

通过QWebView的title()方法,我们可以访问到一个HTML文档的标题,即这个网页的标题。另外,一个网站可能会有站标(就是这个网站的标志,是一个小图标),这时我们可以通过icon()属性来获得站标。如果网站标题或是站标变了,相应的titleChanged() 或是iconChanged()信号会被发送。可以通过textSizeMultiplier()属性来改变QWebView中打开所有网页的文字大小。



如果你需要定制上下文菜单,你可以通过重新实现contextMenuEvent()方法,然后使用pageAction()返回的QAction来构建你的QMenu菜单。

其他功能像重新加载网页,拷贝选择的文字到剪切板以及粘贴到网页,也都可以通过传递给pageAction()方法相应的参数来获得相应的QAction对象。

这些QAction对象可以通过triggerPageAction()方法来触发,另外这些QAction对象也可以被直接加到工具条或是菜单中。QWebView维护这些QAction对象的状态,但也允许修改它们的一些属性,例如文字,图标icon等。



一个QWebView对象可以使用QPrinter的print()方法来实现打印输出,这个方法是一个槽,可以很容易连接到QPrintPreviewDialog的paintRequested()信号上。

为了对网站提供更多的支持,可能你会想允许用户打开新的窗口,例如弹出窗口,这时你可以通过继承QWebView,然后重新实现createWindow()方法即可。



QWebView的元素

QWebView对象由多个对象组成,比如QWebFrame对象和QWebPage对象,下图说明了这些对象之间的关系:



注意:如果不需要QWidget的一些属性,这里可以直接使用QWebPage和QWebFrame,不是说一定要有QWebView才可以。由于QtWebKit依赖于QtGui模块,所以构建程序时应该使用QApplication而不是QCoreApplication。



QWebView继承自QWidget



属性说明



icon : const QIcon

This property holds the icon associated with the web page currently viewed.

这个属性是当前浏览网页的站标,默认情况下,此属性是一个空的图标。

访问方法如下:

01.QIcon icon () const

复制代码跟icon属性相关的还有iconChanged() 和QWebSettings::iconForUrl()。



modified : const bool

这个属性用来表明网页文档是否被用户修改过。

HTML文档的部分内容可以被修改,例如可以通过HTML组成元素的可编辑的属性来修改。

此属性默认值为假。

访问方法如下:

01.bool isModified () const

复制代码renderHints : QPainter::RenderHints

这个属性表明默认网页视图的渲染方式,比如是否抗锯齿等等

此属性可用来在绘制网页前初始化QPainter。

此属性默认值为QPainter::TextAntialiasing



注意:此属性在Symbian上不可用,但其getter和setter方法依然可以直接使用。

这个属性是Qt 4.6才引入的。

访问方法如下:

01.QPainter::RenderHints renderHints () const



02.void setRenderHints ( QPainter::RenderHints hints )

复制代码跟此属性相关的还有QPainter::renderHints().



selectedText : const QString

此属性是当前选择的文字。

默认情况下,此属性为空字符串。



访问方法:

01.QString selectedText () const

复制代码跟此属性相关的还有 findText() 和selectionChanged()。



title : const QString

此属性是当前浏览网页的标题。

默认值为空字符串。

访问方法:

01.QString title () const

复制代码跟此属性相关的还有titleChanged()。



url : QUrl

此属性是当前浏览的网址。

给此属性设置新值后会导致加载新的网址。

此属性默认值为空的,无效的网址。

访问方法:

01.QUrl url () const



02.void setUrl ( const QUrl & url )

复制代码跟此属性相关的还有load() 和 urlChanged()。



zoomFactor : qreal

此属性表明视图放大比例

此属性是Qt 4.5引入的。

访问方法有:

| 0 意見 ]

http://doc.qt.nokia.com/qq/qq03-activex.html



ActiveX under Control
by Volker Hilsheimer

Microsoft's COM technology allows applications and libraries to use components provided by component servers, and to be component servers in their own right. ActiveX is built on the COM technology and defines a set of interfaces for both the client side and the server side. This article introduces the new ActiveQt framework that provides the QAxContainer and QAxServer modules supplied with Qt 3.1's Windows port.
Qt's new ActiveX support allows Qt/Windows developers to access and use ActiveX controls provided by ActiveX servers, and to make their own applications and shared libraries into ActiveX servers. For example, a Qt application could make use of Internet Explorer's ActiveX controls to provide a web page display and navigation to its users. Instead of working with the low-level generic API provided by Microsoft, developers use the QAxWidget class to write standard Qt code using familiar techniques such as signals and slots.
Using a pre-3.1 Qt or a generic ActiveX SDK to create ActiveX controls is very difficult. Qt 3.1's ActiveX support is designed to take the pain out of ActiveX programming. It insulates developers from all the different kinds of generated code that is normally part of an ActiveX implementation. Instead, developers use the QAxServer module to expose any QWidget class as a scriptable ActiveX control.

Using an ActiveX Control

The QAxWidget class uses the COM introspection interfaces (e.g. IDispatch) to generate Qt meta-object information for the ActiveX control it has been initialized with.
    #define CLSID_InternetExplorer "{8856F961-340A-11D0-A96B-00C04FD705A2}"
    QAxWidget *activeX = new QAxWidget( this );
    activeX->setControl( CLSID_InternetExplorer );
The meta-object information adds all the properties and methods exposed by the ActiveX control as Qt properties and slots. This means that we can use Qt's signals and slots mechanism with ActiveX controls. For example, Internet Explorer's GoHome() method becomes a GoHome() slot in Qt:
    connect( homeButton, SIGNAL(clicked()), activeX, SLOT(GoHome()) );
If the ActiveX control provides an event source, the QAxWidget object registers itself as an event sink and makes the events available as Qt signals. Qt's ActiveX framework handles all the type conversions between COM and Qt data types.
    connect( activeX, SIGNAL(TitleChange(const QString&)), 
             this, SLOT(setTitle(const QString&)) );
ActiveX events can be used like any other Qt signals. In this example we've connected Internet Explorer's TitleChange event to our own setTitle() slot.
    activeX->dynamicCall( "Navigate(const QString&)", 
                          "http://doc.trolltech.com" );
The dynamicCall() function allows developers to call a method in an ActiveX control. Qt's ActiveX framework dispatches the call through the IDispatch interface provided by the ActiveX control after doing the type conversions. If a lot of calls need to be made it may be inefficient to use the dynamicCall() approach.
    IWebBrowser *webBrowser = 0;
    activeX->queryInterface( IID_IWebBrowser, &webBrowser );
    if ( webBrowser ) {
       do_something_with( webBrowser );
       webBrowser->Release();
    }
The QAxWidget class provides direct access to the ActiveX control itself through the queryInterface() function. Using the COM interface directly is also useful for accessing methods and properties that have data types which cannot be converted by Qt's ActiveX framework, e.g. properties of type IDispatch *. A notable difference from standard Qt programming is that we must call Release() when we have finished using the control.

Creating an ActiveX Control Server
The ActiveQt framework provides a static library implementing the functions required to turn a standard Qt application or DLL into an ActiveX control server. The qmake build tool adds the necessary modifications to the build system when the list of CONFIG settings in the .pro file includes "activeqt":

    CONFIG += activeqt

Every class inheriting QWidget can be exposed by the server as an ActiveX control. The server must provide a factory that the framework can use to create QWidget objects when they are requested by an ActiveX client. To create an ActiveX server exposing only a single control, it is sufficient to use the default factory as a macro.
    #include 

    QAXFACTORY_DEFAULT( QTetrix, 
                "{852558AD-CBD6-4f07-844C-D1E8983CD6FC}", 
                "{2F5D0068-772C-4d1e-BCD2-D3F6BC7FD315}", 
                "{769F4820-9F28-490f-BA50-5545BD381DCB}", 
                "{5753B1A8-53B9-4abe-8690-6F14EC5CA8D0}", 
                "{DE2F7CE3-CFA7-4938-A9FC-867E2FEB63BA}" );
If the code shown above is added to the Qt Tetrix example (in file qtetrix.cpp), the game will become an ActiveX server. The parameters passed into the macro are unique IDs used by COM to identify the ActiveX control, the interfaces it implements, and its type information. Microsoft supply a tool, guidgen, for generating such IDs. To provide multiple ActiveX controls the factory must be implemented manually. This is achieved by subclassing the QAxFactory class and reimplementing the virtual functions to return information about the supported controls.
The qmake tool will add a build step after the linking of the executable to generate an interface definition file from the information provided by the Qt meta object system. The class's properties, signals and slots will be exposed by the framework as COM properties, methods and events, and will be accessible through the IDispatch automation interface.
Clients using the Tetrix ActiveX control ought to be able to start the game, and be able to read and write the current score, for example to maintain a high score table.
    class QTetrix : public QWidget
    {
        Q_OBJECT
        Q_PROPERTY( int score READ score WRITE setScore )
    public:
        QTetrix( QWidget *parent = 0, const char *name = 0 );
        int score() const;
    public slots:
        void startGame();
        void setScore( int score );
    signals:
        void gameOver();
    };
The Q_PROPERTY macro makes the score accessible to the Qt property system, and the ActiveQt framework exposes it as an ActiveX property. The public slots allow the score to be set and the game to be started using OLE automation, and the gameOver() signal is sent to the hosting client as an ActiveX event.
Applications that are ActiveX servers can also be run as stand alone applications. The following code removes widget functionality that might be inappropriate when they are used as ActiveX controls.
    if ( QAxFactory::isServer() )
        quitButton->hide();
Calling the application with -regserver registers it so that it can be instantiated and scripted by ActiveX clients.
    tetrix -regserver
ActiveX clients can use registered controls, for example
    
    
    
The HTML shown above embeds the QTetrix control into a webpage, and shows a "Start Game" button that will call the startGame() slot of the QTetrix widget.

Summing Up

The QAxContainer module provides QAxWidget, a subclass of QWidget. QAxWidget makes ActiveX methods, properties and events available as Qt slots, properties and signals so that developers can use ActiveX controls just like standard QObjects. The QAxServer module provides an interface between Qt widgets and ActiveX controls. It includes the QAxFactory class that is used to create ActiveX components. Widgets and components created with the QAxServer module can be instantiated and used as standard ActiveX controls by ActiveX client applications and scripting engines such as Internet Explorer and Visual Basic.

| 0 意見 ]

1.QT creator install: 10:45~1200
2.Algorithm: Divide and conquer:13:00~
3.Video processing