abstractformwindow.cpp
来自「奇趣公司比较新的qt/emd版本」· C++ 代码 · 共 780 行 · 第 1/2 页
CPP
780 行
/******************************************************************************** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.**** This file is part of the Qt Designer of the Qt Toolkit.**** This file may be used under the terms of the GNU General Public** License version 2.0 as published by the Free Software Foundation** and appearing in the file LICENSE.GPL included in the packaging of** this file. Please review the following information to ensure GNU** General Public Licensing requirements will be met:** http://trolltech.com/products/qt/licenses/licensing/opensource/**** If you are unsure which license is appropriate for your use, please** review the following information:** http://trolltech.com/products/qt/licenses/licensing/licensingoverview** or contact the sales department at sales@trolltech.com.**** In addition, as a special exception, Trolltech gives you certain** additional rights. These rights are described in the Trolltech GPL** Exception version 1.0, which can be found at** http://www.trolltech.com/products/qt/gplexception/ and in the file** GPL_EXCEPTION.txt in this package.**** In addition, as a special exception, Trolltech, as the sole copyright** holder for Qt Designer, grants users of the Qt/Eclipse Integration** plug-in the right for the Qt/Eclipse Integration to link to** functionality provided by Qt Designer and its related libraries.**** Trolltech reserves all rights not expressly granted herein.**** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.******************************************************************************/#include "abstractformwindow.h"#include <QtGui/QTabBar>#include <QtGui/QSizeGrip>#include <QtGui/QAbstractButton>#include <QtGui/QToolBox>#include <QtGui/QMenuBar>#include <QtGui/QMainWindow>#include <QtGui/QDockWidget>#include <QtGui/QToolBar>#include <QtCore/qdebug.h>/*! \class QDesignerFormWindowInterface \brief The QDesignerFormWindowInterface class allows you to query and manipulate form windows appearing in Qt Designer's workspace. \inmodule QtDesigner QDesignerFormWindowInterface provides information about the associated form window as well as allowing its properties to be altered. The interface is not intended to be instantiated directly, but to provide access to \QD's current form windows controlled by \QD's \l {QDesignerFormWindowManagerInterface}{form window manager}. If you are looking for the form window containing a specific widget, you can use the static QDesignerFormWindowInterface::findFormWindow() function: \code QDesignerFormWindowInterface *formWindow; formWindow = QDesignerFormWindowInterface::findFormWindow(myWidget); \endcode But in addition, you can access any of the current form windows through \QD's form window manager: Use the QDesignerFormEditorInterface::formWindowManager() function to retrieve an interface to the manager. Once you have this interface, you have access to all of \QD's current form windows through the QDesignerFormWindowManagerInterface::formWindow() function. For example: \code QList<QDesignerFormWindowInterface *> forms; QDesignerFormWindowInterface *formWindow; QDesignerFormWindowManagerInterface *manager = formEditor->formWindowManager(); for (int i = 0; i < manager->formWindowCount(); i++) { formWindow = manager->formWindow(i); forms.append(formWindow); } \endcode The pointer to \QD's current QDesignerFormEditorInterface object (\c formEditor in the example above) is provided by the QDesignerCustomWidgetInterface::initialize() function's parameter. When implementing a custom widget plugin, you must subclass the QDesignerCustomWidgetInterface class to expose your plugin to \QD. Once you have the form window, you can query its properties. For example, a plain custom widget plugin is managed by \QD only at its top level, i.e. none of its child widgets can be resized in \QD's workspace. But QDesignerFormWindowInterface provides you with functions that enables you to control whether a widget should be managed by \QD, or not: \code if (formWindow->isManaged(myWidget)) formWindow->manageWidget(myWidget->childWidget); \endcode The complete list of functions concerning widget management is: isManaged(), manageWidget() and unmanageWidget(). There is also several associated signals: widgetManaged(), widgetRemoved(), aboutToUnmanageWidget() and widgetUnmanaged(). In addition to controlling the management of widgets, you can control the current selection in the form window using the selectWidget(), clearSelection() and emitSelectionChanged() functions, and the selectionChanged() signal. You can also retrieve information about where the form is stored using absoluteDir(), its include files using includeHints(), and its layout and pixmap functions using layoutDefault(), layoutFunction() and pixmapFunction(). You can find out whether the form window has been modified (but not saved) or not, using the isDirty() function. You can retrieve its author(), its contents(), its fileName(), associated comment() and exportMacro(), its mainContainer(), its features(), its grid() and its resourceFiles(). The interface provides you with functions and slots allowing you to alter most of this information as well. The exception is the directory storing the form window. Finally, there is several signals associated with changes to the information mentioned above and to the form window in general. \sa QDesignerFormWindowCursorInterface, QDesignerFormEditorInterface, QDesignerFormWindowManagerInterface*//*! \enum QDesignerFormWindowInterface::FeatureFlag This enum describes the features that are available and can be controlled by the form window interface. These values are used when querying the form window to determine which features it supports: \value EditFeature Form editing \value GridFeature Grid display and snap-to-grid facilities for editing \value TabOrderFeature Tab order management \value DefaultFeature Support for default features (form editing and grid) \sa hasFeature(), features()*//*! Constructs a form window interface with the given \a parent and the specified window \a flags.*/QDesignerFormWindowInterface::QDesignerFormWindowInterface(QWidget *parent, Qt::WindowFlags flags) : QWidget(parent, flags){}/*! Destroys the form window interface.*/QDesignerFormWindowInterface::~QDesignerFormWindowInterface(){}/*! Returns a pointer to \QD's current QDesignerFormEditorInterface object.*/QDesignerFormEditorInterface *QDesignerFormWindowInterface::core() const{ return 0;}/*! \fn QDesignerFormWindowInterface *QDesignerFormWindowInterface::findFormWindow(QWidget *widget) Returns the form window interface for the given \a widget.*/static inline bool stopFindAtTopLevel(const QWidget *w){ // Do we need to go beyond top levels when looking for the form window? // 1) A dialog has a window attribute at the moment it is created // before it is properly embedded into a form window. The property // sheet queries the layout attributes precisely at this moment. // 2) In the case of floating toolbars, we also need to go beyond the top level window. if (w->inherits("QDesignerDialog")) return false; if (const QDockWidget *dw = qobject_cast<const QDockWidget *>(w)) if (dw->isFloating()) return false; if (const QToolBar *tb = qobject_cast<const QToolBar *>(w)) if (tb->isFloating()) return false; return true;}QDesignerFormWindowInterface *QDesignerFormWindowInterface::findFormWindow(QWidget *w){ while (w != 0) { if (QDesignerFormWindowInterface *fw = qobject_cast<QDesignerFormWindowInterface*>(w)) { return fw; } else { if (w->isWindow() && stopFindAtTopLevel(w)) break; } w = w->parentWidget(); } return 0;}/*! \fn virtual QString QDesignerFormWindowInterface::fileName() const Returns the file name of the .ui file that describes the form currently being shown. \sa setFileName()*//*! \fn virtual QDir QDesignerFormWindowInterface::absoluteDir() const Returns the absolute location of the directory containing the form shown in the form window.*//*! \fn virtual QString QDesignerFormWindowInterface::contents() const Returns details of the contents of the form currently being displayed in the window.*//*! \fn virtual void QDesignerFormWindowInterface::setContents(QIODevice *device) Sets the form's contents using data obtained from the given \a device. Data can be read from QFile objects or any other subclass of QIODevice.*//*! \fn virtual Feature QDesignerFormWindowInterface::features() const Returns a combination of the features provided by the form window associated with the interface. The value returned can be tested against the \l Feature enum values to determine which features are supported by the window. \sa setFeatures(), hasFeature()*//*! \fn virtual bool QDesignerFormWindowInterface::hasFeature(Feature feature) const Returns true if the form window offers the specified \a feature; otherwise returns false. \sa features()*//*! \fn virtual QString QDesignerFormWindowInterface::author() const Returns details of the author or creator of the form currently being displayed in the window.*//*! \fn virtual void QDesignerFormWindowInterface::setAuthor(const QString &author) Sets the details for the author or creator of the form to the \a author specified.*//*! \fn virtual QString QDesignerFormWindowInterface::comment() const Returns comments about the form currently being displayed in the window.*//*! \fn virtual void QDesignerFormWindowInterface::setComment(const QString &comment) Sets the information about the form to the \a comment specified. This information should be a human-readable comment about the form.*//*! \fn virtual void QDesignerFormWindowInterface::layoutDefault(int *margin, int *spacing) Fills in the default margin and spacing for the form's default layout in the \a margin and \a spacing variables specified.*//*! \fn virtual void QDesignerFormWindowInterface::setLayoutDefault(int margin, int spacing) Sets the default \a margin and \a spacing for the form's layout. \sa layoutDefault()*//*! \fn virtual void QDesignerFormWindowInterface::layoutFunction(QString *margin, QString *spacing) Fills in the current margin and spacing for the form's layout in the \a margin and \a spacing variables specified.*//*! \fn virtual void QDesignerFormWindowInterface::setLayoutFunction(const QString &margin, const QString &spacing) Sets the \a margin and \a spacing for the form's layout. The default layout properties will be replaced by the corresponding layout functions when \c uic generates code for the form, that is, if the functions are specified. This is useful when different environments requires different layouts for the same form. \sa layoutFunction()*//*! \fn virtual QString QDesignerFormWindowInterface::pixmapFunction() const Returns the name of the function used to load pixmaps into the form window. \sa setPixmapFunction()*//*! \fn virtual void QDesignerFormWindowInterface::setPixmapFunction(const QString &pixmapFunction) Sets the function used to load pixmaps into the form window to the given \a pixmapFunction. \sa pixmapFunction()*//*! \fn virtual QString QDesignerFormWindowInterface::exportMacro() const Returns the export macro associated with the form currently being displayed in the window. The export macro is used when the form is compiled to create a widget plugin. \sa {Creating Custom Widgets for Qt Designer}*//*! \fn virtual void QDesignerFormWindowInterface::setExportMacro(const QString &exportMacro) Sets the form window's export macro to \a exportMacro. The export macro is used when building a widget plugin to export the form's interface to other components.*//*! \fn virtual QStringList QDesignerFormWindowInterface::includeHints() const Returns a list of the header files that will be included in the form window's associated \c .ui file. Header files may be local, i.e. relative to the project's directory,\c "mywidget.h", or global, i.e. part of Qt or the compilers standard libraries:\c <QtGui/QWidget>. \sa setIncludeHints()*//*! \fn virtual void QDesignerFormWindowInterface::setIncludeHints(const QStringList &includeHints)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?