/* 输入文件见337.in.txt 输出文件见338.out.txt */ #include <iostream> #include <cctype> #include <fstream> #include <cstring> using namespace std; * + ; //单词表的最大值 + ; //单词长度的最大值 struct WordList { char word[maxWord]; //单词 int fre; //词频 } list[maxList]; char *Delete(char *str,char c) //删除一个单词中的标点符号. 如: declicious! 删去! { char *p = str; //声明一个指针指向自己 char *p2 = str; //如果str自己移动指针的话,最后返回str时,返回的是尾指针,输出为空 while (*p2) { if (*p2 == c) p2++; else *p++ = *p2++; } *p = '\0'; return str; } //因为单词长度不同,所以此函数用来规范输出格式 ) { out << w.word; ; i < findMax - len; i++) { out << extra; } out << w.fre << endl; } int main() { ifstream in("337.in.txt"); //读取单词文件 ofstream out("337.out.txt"); //写入单词及其个数文件 if (!in) { cout << ; } // WordList list[maxList]; //单词表 ; //单词的数量 , lenTmp = ; //查找最大字符串长度 ; string wordMax; char tmp[maxWord]; //读取单词 while (in >> tmp) { int i; lenTmp = strlen(tmp); if (findMax < lenTmp) findMax = lenTmp; // if( !isalpha( tmp[strlen(tmp)-1]) ) //最后一个字符位置不是单词 // Delete(tmp, tmp[strlen(tmp)-1]); //删去一个单词后的标点符号 ; i < N; i++) //在单词表中查找该单词 { ) { //找到则,fre++; list[i].fre++; if (wordFreMax < list[i].fre) { wordFreMax = list[i].fre; wordMax = list[i].word; } break; } } if (i == N) // && isalpha(tmp[0]) 找不到则添加该单词,且该词频置为1,单词表数目N++ { //标点符号不统计 strcpy(list[N].word, tmp); list[N++].fre = ; } } out << "单词表总数:\t" << N << "\n单词频率最高:\t" << wordMax << "\t次数:\t" << wordFreMax << endl; out << "所有单词为:"; ; i < findMax - ; i++) out << ' '; out << "单词数为:\n"; ; i < N; i++) { ShowOrder(list[i], ' ', strlen(list[i].word), out, findMax); //标准化输出 } ; }
//337.in.txt ---- 测试输入数据 ! Search: Go Reference<deque>deque Not logged in registerlog in class template : <deque> ? std::deque ! template < class T, class Alloc = allocator<T> > class deque; Double ended queue deque (usually pronounced like "deck") is an irregular acronym of double-ended queue. Double-ended queues are sequence containers with dynamic sizes that can be expanded or contracted on both ends (either its front or its back). Specific libraries may implement deques in different ways, generally as some form of dynamic array. But in any case, they allow for the individual elements to be accessed directly through random access iterators, with storage handled automatically by expanding and contracting the container as needed. Therefore, they provide a functionality similar to vectors, but with efficient insertion and deletion of elements also at the beginning of the sequence, and not only at its end. But, unlike vectors, deques are not guaranteed to store all its elements in contiguous storage locations: accessing elements in a deque by offsetting a pointer to another element causes undefined behavior. Both vectors and deques provide a very similar interface and can be used for similar purposes, but internally both work in quite different ways: While vectors use a single array that needs to be occasionally reallocated for growth, the elements of a deque can be scattered in different chunks of storage, with the container keeping the necessary information internally to provide direct access to any of its elements in constant time and with a uniform sequential interface (through iterators). Therefore, deques are a little more complex internally than vectors, but this allows them to grow more efficiently under certain circumstances, especially with very long sequences, where reallocations become more expensive. For operations that involve frequent insertion or removals of elements at positions other than the beginning or the end, deques perform worse and have less consistent iterators and references than lists and forward lists. Container properties Sequence Elements in sequence containers are ordered in a strict linear sequence. Individual elements are accessed by their position in this sequence. Dynamic array Generally implemented as a dynamic array, it allows direct access to any element in the sequence and provides relatively fast addition/removal of elements at the beginning or the end of the sequence. Allocator-aware The container uses an allocator object to dynamically handle its storage needs. Template parameters T Type of the elements. Aliased as member type deque::value_type. Alloc Type of the allocator object used to define the storage allocation model. By default, the allocator class template is used, which defines the simplest memory allocation model and is value-independent. Aliased as member type deque::allocator_type. Member types C++98C++ member type definition notes value_type The first template parameter (T) allocator_type The second template parameter (Alloc) defaults to: allocator<value_type> reference allocator_type::reference for the default allocator: value_type& const_reference allocator_type::const_reference for the default allocator: const value_type& pointer allocator_type::pointer for the default allocator: value_type* const_pointer allocator_type::const_pointer for the default allocator: const value_type* iterator a random access iterator to value_type convertible to const_iterator const_iterator a random access iterator to const value_type reverse_iterator reverse_iterator<iterator> const_reverse_iterator reverse_iterator<const_iterator> difference_type a signed integral type, identical to: iterator_traits<iterator>::difference_type usually the same as ptrdiff_t size_type an unsigned integral type that can represent any non-negative value of difference_type usually the same as size_t Member functions (constructor) Construct deque container (public member function ) (destructor) Deque destructor (public member function ) operator= Assign content (public member function ) Iterators: begin Return iterator to beginning (public member function ) end Return iterator to end (public member function ) rbegin Return reverse iterator to reverse beginning (public member function ) rend Return reverse iterator to reverse end (public member function ) cbegin Return const_iterator to beginning (public member function ) cend Return const_iterator to end (public member function ) crbegin Return const_reverse_iterator to reverse beginning (public member function ) crend Return const_reverse_iterator to reverse end (public member function ) Capacity: size Return size (public member function ) max_size Return maximum size (public member function ) resize Change size (public member function ) empty Test whether container is empty (public member function ) shrink_to_fit Shrink to fit (public member function ) Element access: operator[] Access element (public member function ) at Access element (public member function ) front Access first element (public member function ) back Access last element (public member function ) Modifiers: assign Assign container content (public member function ) push_back Add element at the end (public member function ) push_front Insert element at beginning (public member function ) pop_back Delete last element (public member function ) pop_front Delete first element (public member function ) insert Insert elements (public member function ) erase Erase elements (public member function ) swap Swap content (public member function ) clear Clear content (public member function ) emplace Construct and insert element (public member function ) emplace_front Construct and insert element at beginning (public member function ) emplace_back Construct and insert element at the end (public member function ) Allocator: get_allocator Get allocator (public member function ) Non-member functions overloads relational operators Relational operators for deque (function ) swap Exchanges the contents of two deque containers (function template ) C++ Information Tutorials Reference Articles Forum Reference C library: Containers: <array> <deque> <forward_list> <list> <map> <queue> <set> <stack> <unordered_map> <unordered_set> <vector> Input/Output: Multi-threading: Other: <deque> deque deque deque::deque deque::~deque member functions: deque::assign deque::at deque::back deque::begin deque::cbegin deque::cend deque::clear deque::crbegin deque::crend deque::emplace deque::emplace_back deque::emplace_front deque::empty deque::end deque::erase deque::front deque::get_allocator deque::insert deque::max_size deque::operator= deque::operator[] deque::pop_back deque::pop_front deque::push_back deque::push_front deque::rbegin deque::rend deque::resize deque::shrink_to_fit deque::size deque::swap non-member overloads: relational operators (deque) swap (deque) Home page | Privacy policy ? cplusplus.com, - - All rights reserved - v3. Spotted an error? contact us Download Device Creation Application Development Services Developers Wiki Documentation Forum Bug Reports Code Review Qt Documentation Qt 5.7 Qt Licensing Contents Purchasing and Sales Information Licenses Used in Qt Additional information Reference All Qt C++ Classes All QML Types All Qt Modules Qt Creator Manual All Qt Reference Documentation Getting Started Getting Started with Qt What's New in Qt 5 Examples and Tutorials Supported Platforms Qt Licensing Overviews Development Tools User Interfaces Core Internals Data Storage Multimedia Networking and Connectivity Graphics Mobile APIs QML Applications All Qt Overviews Qt Licensing Qt is available under different licensing options designed to accommodate the needs of our various users: Qt licensed under commercial licenses are appropriate . Qt licensed under the GNU Lesser General Public License (LGPL) version (or GNU GPL version ). Note: Some specific parts (modules) of the Qt framework are not available under the GNU LGPL version , but under the GNU General Public License (GPL) instead. See Licenses Used in Qt for details. Qt documentation is licensed under the terms of the GNU Free Documentation License (FDL) version 1.3, as published by the Free Software Foundation. Alternatively, you may use the documentation in accordance with the terms contained in a written agreement between you and The Qt Company. See http://qt.io/licensing/ for an overview of Qt licensing. Purchasing and Sales Information To purchase a Qt license, visit http://www.qt.io/download/. For further information and assistance about Qt licensing, contact our sales; see http://www.qt.io/locations/ for contact details. Licenses Used in Qt The following table lists parts of Qt that incorporate code licensed under licenses other than GNU Lesser General Public License (LGPL) or the commercial license, as well as Qt modules that are only available under a specific license or a version of a license. Third-party licenses used in libraries that are supplied alongside Qt modules are also listed. Note: Cross-module dependencies are also described on a general level. All Qt modules depend on Qt Core. Qt Module/Tool Component Description License Type Notes Qt Core QSegfaultHandler Parts of implementation of QSegfaultHandler class. BSD-style QUrl Implementation of QUrl::fromUserInput(). Modified BSD Cocoa Platform Plugin Specific parts of the Qt for OS X Cocoa port. BSD-style Qt for OS X qtmain library A helper library for writing a cross-platform main() function on Windows. Modified BSD Qt for Windows Shift-JIS Text Codec A character encoding for Japanese. BSD-style ISO--JP (JIS) Text Codec A widely used encoding for Japanese. BSD-style EUC-JP Text Codec EUC-JP is a variable-width encoding used to represent the elements of three Japanese character set standards. BSD-style EUC-KR TextCodec Extended Unix Code (EUC) is a multibyte character encoding system used primarily for Japanese, Korean, and simplified Chinese. BSD-style GBK Text Codec GBK is an extension of the GB2312 character set for simplified Chinese characters, used mainland China. BSD-style Big5 Text Codec Big5, or BIG-, is a Chinese character encoding method used for Traditional Chinese characters. BSD-style Big5-HKSCS Text Codec Big5-HKSCS characters. BSD-style TSCII Text Codec The TSCII codec provides conversion to and from the Tamil TSCII encoding. BSD-style Stack-less Just-In-Time compiler A platform-independent JIT compiler. BSD Parts of the codecs implemented by Qt BSD Unicode Unicode character data. Permissive, GPL-compatible Macros for building Qt files Macros used in CMake files for building Qt. BSD The PCRE library The PCRE library . BSD-style Third-party Licenses Android C++ Run-time GNU C++ run-time library (libstdc++) for Android. GPLv3 with exception Qt for Android forkfd A tool to facilitate spawning sub-processes. MIT Unix systems FreeBSD strtoll and strtoull Functions for converting a string to long long integer. BSD V8 double/string conversion library Functions for converting between strings and doubles. BSD MD4 implements the MD4 message-digest algorithm. BSD MD5 implements the MD5 message-digest algorithm. BSD Mesa llvmpipe Mesa llvmpipe software rasterizer backend (opengl32sw.dll) for Windows builds. MIT Qt for Windows SHA- implements the SHA- encryption algorithm. BSD SHA- implements the SHA- encryption algorithm. BSD zlib zlib is a general purpose data compression library. BSD-style The Public Suffix List A list of all known public Internet suffixes. Mozilla Public License Qt Gui QKeyMapper Internal class for key mapping. Custom, BSD-style Qt for Linux/X11 QImage Code used for smooth scaling in QImage::transformed(). BSD Third-party Licenses FreeType Parts of FreeType project used in font rendering. GPLv2, FreeType Project License HarfBuzz OpenType layout engine. BSD-style FreeType Parts of FreeType project used in font rendering. GPLv2, FreeType Project License PNG Reference Library A library for reducing the time and effort it takes to support the PNG format. BSD-style Pixman Pixman is a library that provides low-level pixel manipulation features such as image compositing and trapezoid rasterization. BSD-style Drag and Drop Allows users to transfer information between and within applications. BSD-style ANGLE Opensource project to map OpenGL ES API calls to DirectX API. BSD-style Qt for Windows Qt Location Third-party Licenses Poly2Tri Poly2Tri is a sweepline constrained Delaunay Polygon Triangulation Library. BSD-style Qt Multimedia Third-party Licenses FFTReal Fast Fourier transform of real-valued arrays. LGPL (Used in example code). Qt Canvas 3D Third-party Licenses three.js JavaScript 3D library MIT (Used in example code) Three.js Loader A parser for loading 3D models from JSON data structures. MIT (Used in example code). gl-matrix.js High performance matrix and vector operations MIT (Used in example code). Qt SVG Qt SVG License Information Parts of code for arc handling in Qt SVG module. BSD-style Depends on Qt Gui, Qt Widgets Qt Quick Third-party Licenses Easing Equations Easing Equations is a collection of swappable functions that add flavor to motion. BSD-style Depends on Qt QML, Qt Gui, Qt Network Qt Quick Controls Native Style for Android Apache License 2.0 Qt for Android Qt Script (Provided compatibility) V8 benchmark tests V8 benchmark tests used in Qt Script. BSD-style Sunspider benchmark tests Sunspider benchmark tests used in Qt Script. BSD-style Third-party Licenses JavaScriptCore LGPL v2 Qt Test Testlib Parts of implementation of Qt Test library. BSD, MIT Third-party Licenses Valgrind A code analysis tool for detecting memory leaks. GPL v2 valgrind.h specific license BSD-style Callgrind A performance profiling tool. GPL v2 Qt Print Support Depends on Qt Gui and Qt Widgets PDF Licensing Notes about PDF Licensing. Qt Wayland Wayland Protocol MIT Qt WebEngine Qt WebEngine Core LGPL v3 or GPL v2 + Qt commercial license Third-party Licenses Chromium Third-party licenses , BSD, BSL, Apache, APSL, MIT, MPL, others See Qt WebEngine Licensing for details. Qt Designer Qt Designer License Information Implementation of the recursive shadow casting algorithm in Qt Designer. BSD (MIT) Qt Creator Third-party Licenses Botan A C++ crypto library used in Qt Creator. BSD Qt Image Formats Third-party Licenses JasPer A collection of software for the coding and manipulation of images. BSD-style TIFF libtiff is a set of C functions (a library) that support the manipulation of TIFF image files. BSD MNG Support decoding and displaying of MNG format image files. BSD-style WebP Support decoding and displaying of WebP format image files. BSD-style Qt SQL SQLite A C library that implements a self-contained, embeddable, zero-configuration SQL database engine. BSD-style Qt XML Patterns Bison Parser Bison is a parser generator. GPL with exception Depends on Qt Network Qt 3D Third-party Licenses assimp Open Asset Import Library BSD Plugins JPEG C software to implement JPEG image compression and decompression. BSD-style IAccessible2 An accessibility API for Microsoft Windows applications. BSD Qt for Windows Cycle A CPU tick counter. MIT callgrind.h specific license BSD-style xcb A C language binding for the X Window System. BSD-style Qt for Linux/X11 at-spi and at-spi2 A toolkit-neutral way of providing accessibility facilities in application. LGPL Qt for Linux/X11 xkbcommon Keymap handling library for toolkits and window systems. BSD-style Qt for Linux/X11 Qt Tools Third-party Licenses Clucene Core Library A high-performance, full-featured text search engine written in C++. LGPL/Apache The following modules are available under the GNU GPL version and commercial licenses: Qt Module/Tool Component Description License Type Qt Charts GPLv3 or commercial license Qt Data Visualization GPLv3 or commercial license Qt Purchasing GPLv3 or commercial license Qt Virtual Keyboard GPLv3 or commercial license Third-party Licenses Lipi Toolkit An open source toolkit for online Handwriting Recognition (HWR). MIT-Style License OpenWnn A Japanese IME Apache License Pinyin An IME for Standard Chinese input. Apache License tcime A traditional Chinese IME. Apache License Qt Quick 2D Renderer GPLv3 or commercial license Third-party Licenses EGL 1.5 Headers These headers are based on EGL 1.5 specification. MIT License OpenGL ES 2.0 Headers These headers are based on OpenGL ES 2.0 specification. MIT and SGI License OpenGL ES 3.1 Headers These headers are based on OpenGL ES 3.1 specification. MIT and SGI License OpenKODE Core 1.0 Header The header is based on OpenKODE Core 1.0 specification. MIT License Qt Qml Third-party Licenses JavaScriptCore Macro Assembler The assembly code generated use by the JIT. BSD-style Additional information The documents below list related documents, such as information about Trademark and other licenses used in parts of Qt. Android GNU C++ Run-time Licensing Provides additional information about the licensing of run-time dependencies of Qt for Android Contributions to the Cocoa Platform Plugin Files License information for contributions by Apple, Inc. to specific parts of the Qt for OS X Cocoa port. Licenses for Fonts Used in Qt for Embedded Linux Information about the licenses of fonts supplied with Qt Notes about PDF Licensing Details of restrictions on the use of PDF-related trademarks. Open Source Licensing of Qt Information about open source licensing of Qt. Qt SVG License Information License information for Qt SVG The qtmain Library Describes the use and license of the qtmain helper library. Third-Party Licenses Used in Qt License information for third-party libraries supplied with Qt. Trademarks Information about trademarks owned by The Qt Company and other organizations. ? The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners. Download Start for Free Qt for Application Development Qt for Device Creation Qt Open Source Terms & Conditions Licensing FAQ Product Qt in Use Qt for Application Development Qt for Device Creation Commercial Features Qt Creator IDE Qt Quick Services Technology Evaluation Proof of Concept Design & Implementation Productization Qt Training Partner Network Developers Documentation Examples & Tutorials Development Tools Wiki Forums Contribute to Qt About us Training & Events Resource Center News Careers Locations Contact Us Qt MerchandiseSign InFeedback? The Qt Company Download Device Creation Application Development Services Developers Wiki Documentation Forum Bug Reports Code Review Qt Documentation Qt 5.7 Qt Core C++ Classes QObject Contents Properties Public Functions Public Slots Signals Static Public Members Protected Functions Related Non-Members Macros Detailed Description Thread Affinity No Copy Constructor or Assignment Operator Auto-Connection Dynamic Properties Internationalization (I18n) Reference All Qt C++ Classes All QML Types All Qt Modules Qt Creator Manual All Qt Reference Documentation Getting Started Getting Started with Qt What's New in Qt 5 Examples and Tutorials Supported Platforms Qt Licensing Overviews Development Tools User Interfaces Core Internals Data Storage Multimedia Networking and Connectivity Graphics Mobile APIs QML Applications All Qt Overviews QObject Class The QObject class is the base class of all Qt objects. More... Header: #include <QObject> qmake: QT += core Instantiated By: QtObject Inherited By: Q3DObject, Q3DScene, Q3DTheme, QAbstract3DAxis, QAbstract3DInputHandler, QAbstract3DSeries, QAbstractAnimation, QAbstractAxis, QAbstractDataProxy, QAbstractEventDispatcher, QAbstractItemDelegate, QAbstractItemModel, QAbstractMessageHandler, QAbstractNetworkCache, QAbstractSeries, QAbstractState, QAbstractTextDocumentLayout, QAbstractTransition, QAbstractUriResolver, QAbstractVideoFilter, QAbstractVideoSurface, QAccessiblePlugin, QAction, QActionGroup, QAudioInput, QAudioOutput, QAudioProbe, QAxFactory, QAxObject, QAxScript, QAxScriptManager, QBarSet, QBluetoothDeviceDiscoveryAgent, QBluetoothLocalDevice, QBluetoothServer, QBluetoothServiceDiscoveryAgent, QBluetoothTransferManager, QBluetoothTransferReply, QBoxSet, QButtonGroup, QCameraExposure, QCameraFocus, QCameraImageCapture, QCameraImageProcessing, QCanBus, QCanBusDevice, QClipboard, QCompleter, QCoreApplication, QCustom3DItem, QDataWidgetMapper, QDBusAbstractAdaptor, QDBusAbstractInterface, QDBusPendingCallWatcher, QDBusServer, QDBusServiceWatcher, QDBusVirtualObject, QDesignerFormEditorInterface, QDesignerFormWindowManagerInterface, QDnsLookup, QDrag, QEventLoop, QExtensionFactory, QExtensionManager, QFileSelector, QFileSystemWatcher, QGamepad, QGenericPlugin, QGeoAreaMonitorSource, QGeoCodeReply, QGeoCodingManager, QGeoCodingManagerEngine, QGeoPositionInfoSource, QGeoRouteReply, QGeoRoutingManager, QGeoRoutingManagerEngine, QGeoSatelliteInfoSource, QGeoServiceProvider, QGesture, QGLShader, QGLShaderProgram, QGraphicsAnchor, QGraphicsEffect, QGraphicsItemAnimation, QGraphicsObject, QGraphicsScene, QGraphicsTransform, QHelpEngineCore, QHelpSearchEngine, QHttpMultiPart, QIconEnginePlugin, QImageIOPlugin, QInAppProduct, QInAppStore, QInAppTransaction, QInputMethod, QIODevice, QItemSelectionModel, QJSEngine, QLayout, QLegendMarker, QLibrary, QLocalServer, QLowEnergyController, QLowEnergyService, QMacToolBar, QMacToolBarItem, QMaskGenerator, QMediaControl, QMediaObject, QMediaPlaylist, QMediaRecorder, QMediaService, QMediaServiceProviderPlugin, QMimeData, QModbusDevice, QModbusReply, QMovie, QNearFieldManager, QNearFieldShareManager, QNearFieldShareTarget, QNearFieldTarget, QNetworkAccessManager, QNetworkConfigurationManager, QNetworkCookieJar, QNetworkSession, QObjectCleanupHandler, QOffscreenSurface, QOpenGLContext, QOpenGLContextGroup, QOpenGLDebugLogger, QOpenGLShader, QOpenGLShaderProgram, QOpenGLTimeMonitor, QOpenGLTimerQuery, QOpenGLVertexArrayObject, QPdfWriter, QPictureFormatPlugin, QPieSlice, QPlaceManager, QPlaceManagerEngine, QPlaceReply, QPlatformGraphicsBuffer, QPlatformSystemTrayIcon, QPluginLoader, QQmlComponent, QQmlContext, QQmlExpression, QQmlExtensionPlugin, QQmlFileSelector, QQmlNdefRecord, QQmlPropertyMap, QQuickImageResponse, QQuickItem, QQuickItemGrabResult, QQuickRenderControl, QQuickTextDocument, QQuickTextureFactory, QQuickWebEngineProfile, QRadioData, QScreen, QScriptEngine, QScriptEngineDebugger, QScriptExtensionPlugin, QScroller, QScxmlDataModel, QScxmlStateMachine, QSensor, QSensorBackend, QSensorGesture, QSensorGestureManager, QSensorGestureRecognizer, QSensorReading, QSessionManager, QSettings, QSGAbstractRenderer, QSGEngine, QSGTexture, QSGTextureProvider, QSharedMemory, QShortcut, QSignalMapper, QSignalSpy, QSocketNotifier, QSound, QSoundEffect, QSqlDriver, QSqlDriverPlugin, QStyle, QStyleHints, QStylePlugin, QSvgRenderer, QSyntaxHighlighter, QSystemTrayIcon, Qt3DCore::QAbstractAspect, Qt3DCore::QAspectEngine, Qt3DCore::QNode, Qt3DCore::Quick::QQmlAspectEngine, Qt3DInput::QKeyEvent, Qt3DInput::QMouseEvent, Qt3DInput::QWheelEvent, Qt3DRender::QGraphicsApiFilter, Qt3DRender::QPickEvent, Qt3DRender::QTextureWrapMode, QTcpServer, QTextDocument, QTextObject, QThread, QThreadPool, QTimeLine, QTimer, QTranslator, QtVirtualKeyboard::InputContext, QtVirtualKeyboard::InputEngine, QtVirtualKeyboard::ShiftHandler, QUiLoader, QUndoGroup, QUndoStack, QValidator, QValue3DAxisFormatter, QVideoProbe, QWaylandClient, QWaylandSurfaceGrabber, QWaylandView, QWebChannel, QWebChannelAbstractTransport, QWebEngineCookieStore, QWebEngineDownloadItem, QWebEnginePage, QWebEngineProfile, QWebEngineUrlRequestInterceptor, QWebEngineUrlRequestJob, QWebEngineUrlSchemeHandler, QWebSocket, QWebSocketServer, QWidget, QWindow, QWinEventNotifier, QWinJumpList, QWinTaskbarButton, QWinTaskbarProgress, QWinThumbnailToolBar, and QWinThumbnailToolButton List of all members, including inherited members Obsolete members Note: All functions in this class are reentrant. Note: These functions are also thread-safe: connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) connect(const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) connect(const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type) connect(const QObject *sender, PointerToMemberFunction signal, Functor functor) connect(const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type) disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method) disconnect(const char *signal, const QObject *receiver, const char *method) disconnect(const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method) Properties objectName : QString Public Functions QObject(QObject *parent = Q_NULLPTR) virtual ~QObject() bool blockSignals(bool block) const QObjectList & children() const QMetaObject::Connection connect(const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type = Qt::AutoConnection) const bool disconnect(const char *signal = Q_NULLPTR, const QObject *receiver = Q_NULLPTR, const char *method = Q_NULLPTR) const bool disconnect(const QObject *receiver, const char *method = Q_NULLPTR) const void dumpObjectInfo() void dumpObjectTree() QList<QByteArray> dynamicPropertyNames() const virtual bool event(QEvent *e) virtual bool eventFilter(QObject *watched, QEvent *event) T findChild(const QString &name = QString(), Qt::FindChildOptions options = Qt::FindChildrenRecursively) const QList<T> findChildren(const QString &name = QString(), Qt::FindChildOptions options = Qt::FindChildrenRecursively) const QList<T> findChildren(const QRegExp ®Exp, Qt::FindChildOptions options = Qt::FindChildrenRecursively) const QList<T> findChildren(const QRegularExpression &re, Qt::FindChildOptions options = Qt::FindChildrenRecursively) const bool inherits(const char *className) const void installEventFilter(QObject *filterObj) bool isWidgetType() const bool isWindowType() const void killTimer(int id) virtual const QMetaObject * metaObject() const void moveToThread(QThread *targetThread) QString objectName() const QObject * parent() const QVariant property(const char *name) const void removeEventFilter(QObject *obj) void setObjectName(const QString &name) void setParent(QObject *parent) bool setProperty(const char *name, const QVariant &value) bool signalsBlocked() const int startTimer(int interval, Qt::TimerType timerType = Qt::CoarseTimer) QThread * thread() const Public Slots void deleteLater() Signals void destroyed(QObject *obj = Q_NULLPTR) void objectNameChanged(const QString &objectName) Static Public Members QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type = Qt::AutoConnection) QMetaObject::Connection connect(const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type = Qt::AutoConnection) QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type = Qt::AutoConnection) QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor) QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type = Qt::AutoConnection) bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method) bool disconnect(const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) bool disconnect(const QMetaObject::Connection &connection) bool disconnect(const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method) const QMetaObject staticMetaObject QString tr() Protected Functions virtual void childEvent(QChildEvent *event) virtual void connectNotify(const QMetaMethod &signal) virtual void customEvent(QEvent *event) virtual void disconnectNotify(const QMetaMethod &signal) bool isSignalConnected(const QMetaMethod &signal) const int receivers(const char *signal) const QObject * sender() const int senderSignalIndex() const virtual void timerEvent(QTimerEvent *event) Related Non-Members typedef QObjectList QList<T> qFindChildren(const QObject *obj, const QRegExp ®Exp) T qobject_cast(QObject *object) Macros Q_CLASSINFO(Name, Value) Q_DISABLE_COPY(Class) Q_EMIT Q_ENUM(...) Q_FLAG(...) Q_GADGET Q_INTERFACES(...) Q_INVOKABLE Q_OBJECT Q_PROPERTY(...) Q_REVISION Q_SET_OBJECT_NAME(Object) Q_SIGNAL Q_SIGNALS Q_SLOT Q_SLOTS Detailed Description The QObject class is the base class of all Qt objects. QObject is the heart of the Qt Object Model. The central feature in this model is a very powerful mechanism for seamless object communication called signals and slots. You can connect a signal to a slot with connect() and destroy the connection with disconnect(). To avoid never ending notification loops you can temporarily block signals with blockSignals(). The protected functions connectNotify() and disconnectNotify() make it possible to track connections. QObjects organize themselves in object trees. When you create a QObject with another object as parent, the object will automatically add itself to the parent's children() list. The parent takes ownership of the object; i.e., it will automatically delete its children in its destructor. You can look for an object by name and optionally type using findChild() or findChildren(). Every object has an objectName() and its class name can be found via the corresponding metaObject() (see QMetaObject::className()). You can determine whether the object's class inherits another class in the QObject inheritance hierarchy by using the inherits() function. When an object is deleted, it emits a destroyed() signal. You can catch this signal to avoid dangling references to QObjects. QObjects can receive events through event() and filter the events of other objects. See installEventFilter() and eventFilter() for details. A convenience handler, childEvent(), can be reimplemented to catch child events. Last but not least, QObject provides the basic timer support in Qt; see QTimer for high-level support for timers. Notice that the Q_OBJECT macro is mandatory for any object that implements signals, slots or properties. You also need to run the Meta Object Compiler on the source file. We strongly recommend the use of this macro in all subclasses of QObject regardless of whether or not they actually use signals, slots and properties, since failure to do so may lead certain functions to exhibit strange behavior. All Qt widgets inherit QObject. The convenience function isWidgetType() returns whether an object is actually a widget. It is much faster than qobject_cast<QWidget *>(obj) or obj->inherits("QWidget"). Some QObject functions, e.g. children(), return a QObjectList. QObjectList is a typedef for QList<QObject *>. Thread Affinity A QObject instance is said to have a thread affinity, or that it lives in a certain thread. When a QObject receives a queued signal or a posted event, the slot or event handler will run in the thread that the object lives in. Note: If a QObject has no thread affinity (that is, if thread() returns zero), or if it lives in a thread that has no running event loop, then it cannot receive queued signals or posted events. By default, a QObject lives in the thread in which it is created. An object's thread affinity can be queried using thread() and changed using moveToThread(). All QObjects must live in the same thread as their parent. Consequently: setParent() will fail if the two QObjects involved live in different threads. When a QObject is moved to another thread, all its children will be automatically moved too. moveToThread() will fail if the QObject has a parent. If QObjects are created within QThread::run(), they cannot become children of the QThread object because the QThread does not live in the thread that calls QThread::run(). Note: A QObject's member variables do not automatically become its children. The parent-child relationship must be set by either passing a pointer to the child's constructor, or by calling setParent(). Without this step, the object's member variables will remain in the old thread when moveToThread() is called. No Copy Constructor or Assignment Operator QObject has neither a copy constructor nor an assignment operator. This is by design. Actually, they are declared, but in a private section with the macro Q_DISABLE_COPY(). In fact, all Qt classes derived from QObject (direct or indirect) use this macro to declare their copy constructor and assignment operator to be private. The reasoning is found in the discussion on Identity vs Value on the Qt Object Model page. The main consequence is that you should use pointers to QObject (or to your QObject subclass) where you might otherwise be tempted to use your QObject subclass as a value. For example, without a copy constructor, you can't use a subclass of QObject as the value to be stored in one of the container classes. You must store pointers. Auto-Connection Qt's meta-object system provides a mechanism to automatically connect signals and slots between QObject subclasses and their children. As long as objects are defined with suitable object names, and slots follow a simple naming convention, this connection can be performed at run-time by the QMetaObject::connectSlotsByName() function. uic generates code that invokes this function to enable auto-connection to be performed between widgets on forms created with Qt Designer. More information about using auto-connection with Qt Designer is given in the Using a Designer UI File in Your Application section of the Qt Designer manual. Dynamic Properties From Qt 4.2, dynamic properties can be added to and removed from QObject instances at run-time. Dynamic properties do not need to be declared at compile-time, yet they provide the same advantages as static properties and are manipulated using the same API - using property() to read them and setProperty() to write them. From Qt 4.3, dynamic properties are supported by Qt Designer, and both standard Qt widgets and user-created forms can be given dynamic properties. Internationalization (I18n) All QObject subclasses support Qt's translation features, making it possible to translate an application's user interface into different languages. To make user-visible text translatable, it must be wrapped in calls to the tr() function. This is explained in detail in the Writing Source Code for Translation document. See also QMetaObject, QPointer, QObjectCleanupHandler, Q_DISABLE_COPY(), and Object Trees & Ownership. Property Documentation objectName : QString This property holds the name of this object. You can find an object by name (and type) using findChild(). You can find a set of objects with findChildren(). qDebug("MyClass::setPrecision(): (%s) invalid precision %f", qPrintable(objectName()), newPrecision); By default, this property contains an empty string. Access functions: QString objectName() const void setObjectName(const QString &name) Notifier signal: void objectNameChanged(const QString &objectName) [see note below] Note: This is a private signal. It can be used in signal connections but cannot be emitted by the user. See also metaObject() and QMetaObject::className(). Member Function Documentation QObject::QObject(QObject *parent = Q_NULLPTR) Constructs an object with parent object parent. The parent of an object may be viewed as the object's owner. For instance, a dialog box is the parent of the OK and Cancel buttons it contains. The destructor of a parent object destroys all child objects. Setting parent to constructs an object with no parent. If the object is a widget, it will become a top-level window. See also parent(), findChild(), and findChildren(). [virtual] QObject::~QObject() Destroys the object, deleting all its child objects. All signals to and from the object are automatically disconnected, and any pending posted events for the object are removed from the event queue. However, it is often safer to use deleteLater() rather than deleting a QObject subclass directly. Warning: All child objects are deleted. If any of these objects are on the stack or global, sooner or later your program will crash. We do not recommend holding pointers to child objects from outside the parent. If you still do, the destroyed() signal gives you an opportunity to detect when an object is destroyed. Warning: Deleting a QObject while pending events are waiting to be delivered can cause a crash. You must not delete the QObject directly if it exists in a different thread than the one currently executing. Use deleteLater() instead, which will cause the event loop to delete the object after all pending events have been delivered to it. See also deleteLater(). bool QObject::blockSignals(bool block) If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). If block is false, no such blocking will occur. The return value is the previous value of signalsBlocked(). Note that the destroyed() signal will be emitted even if the signals for this object have been blocked. Signals emitted while being blocked are not buffered. See also signalsBlocked() and QSignalBlocker. [virtual protected] void QObject::childEvent(QChildEvent *event) This event handler can be reimplemented in a subclass to receive child events. The event is passed in the event parameter. QEvent::ChildAdded and QEvent::ChildRemoved events are sent to objects when children are added or removed. In both cases you can only rely on the child being a QObject, or if isWidgetType() returns true, a QWidget. (This is because, in the ChildAdded case, the child is not yet fully constructed, and in the ChildRemoved case it might have been destructed already). QEvent::ChildPolished events are sent to widgets when children are polished, or when polished children are added. If you receive a child polished event, the child's construction is usually completed. However, this is not guaranteed, and multiple polish events may be delivered during the execution of a widget's constructor. For every child widget, you receive one ChildAdded event, zero or more ChildPolished events, and one ChildRemoved event. The ChildPolished event is omitted if a child is removed immediately after it is added. If a child is polished several times during construction and destruction, you may receive several child polished events for the same child, each time with a different virtual table. See also event(). const QObjectList &QObject::children() const Returns a list of child objects. The QObjectList class is defined in the <QObject> header file as the following: typedef QList<QObject*> QObjectList; The first child added is the first object in the list and the last child added is the last object in the list, i.e. new children are appended at the end. Note that the list order changes when QWidget children are raised or lowered. A widget that is raised becomes the last object in the list, and a widget that is lowered becomes the first object in the list. See also findChild(), findChildren(), parent(), and setParent(). [static] QMetaObject::Connection QObject::connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type = Qt::AutoConnection) Creates a connection of the given type from the signal in the sender object to the method in the receiver object. Returns a handle to the connection that can be used to disconnect it later. You must use the SIGNAL() and SLOT() macros when specifying the signal and the method, for example: QLabel *label = new QLabel; QScrollBar *scrollBar = new QScrollBar; QObject::connect(scrollBar, SIGNAL(valueChanged(int)), label, SLOT(setNum(int))); This example ensures that the label always displays the current scroll bar value. Note that the signal and slots parameters must not contain any variable names, only the type. E.g. the following would not work and return false: // WRONG QObject::connect(scrollBar, SIGNAL(valueChanged(int value)), label, SLOT(setNum(int value))); A signal can also be connected to another signal: class MyWidget : public QWidget { Q_OBJECT public: MyWidget(); signals: void buttonClicked(); private: QPushButton *myButton; }; MyWidget::MyWidget() { myButton = new QPushButton(this); connect(myButton, SIGNAL(clicked()), this, SIGNAL(buttonClicked())); } In this example, the MyWidget constructor relays a signal from a private member variable, and makes it available under a name that relates to MyWidget. A signal can be connected to many slots and signals. Many signals can be connected to one slot. If a signal is connected to several slots, the slots are activated in the same order in which the connections were made, when the signal is emitted. The function returns a QMetaObject::Connection that represents a handle to a connection if it successfully connects the signal to the slot. The connection handle will be invalid if it cannot create the connection, for example, if QObject is unable to verify the existence of either signal or method, or if their signatures aren't compatible. You can check if the handle is valid by casting it to a bool. By default, a signal is emitted for every connection you make; two signals are emitted for duplicate connections. You can break all of these connections with a single disconnect() call. If you pass the Qt::UniqueConnection type, the connection will only be made if it is not a duplicate. If there is already a duplicate (exact same signal to the exact same slot on the same objects), the connection will fail and connect will return an invalid QMetaObject::Connection. The optional type parameter describes the type of connection to establish. In particular, it determines whether a particular signal is delivered to a slot immediately or queued for delivery at a later time. If the signal is queued, the parameters must be of types that are known to Qt's meta-object system, because Qt needs to copy the arguments to store them in an event behind the scenes. If you try to use a queued connection and get the error message QObject::connect: Cannot queue arguments of type 'MyType' (Make sure 'MyType' is registered using qRegisterMetaType().) call qRegisterMetaType() to register the data type before you establish the connection. Note: This function is thread-safe See also disconnect(), sender(), qRegisterMetaType(), and Q_DECLARE_METATYPE(). [static] QMetaObject::Connection QObject::connect(const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type = Qt::AutoConnection) Creates a connection of the given type from the signal in the sender object to the method in the receiver object. Returns a handle to the connection that can be used to disconnect it later. The Connection handle will be invalid if it cannot create the connection, for example, the parameters were invalid. You can check if the QMetaObject::Connection is valid by casting it to a bool. This function works in the same way as connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) but it uses QMetaMethod to specify signal and method. This function was introduced in Qt 4.8. See also connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type). QMetaObject::Connection QObject::connect(const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type = Qt::AutoConnection) const This function overloads connect(). Connects signal from the sender object to this object's method. Equivalent to connect(sender, signal, this, method, type). Every connection you make emits a signal, so duplicate connections emit two signals. You can break a connection using disconnect(). Note: This function is thread-safe See also disconnect(). [static] QMetaObject::Connection QObject::connect(const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type = Qt::AutoConnection) This function overloads connect(). Creates a connection of the given type from the signal in the sender object to the method in the receiver object. Returns a handle to the connection that can be used to disconnect it later. The signal must be a function declared as a signal in the header. The slot function can be any member function that can be connected to the signal. A slot can be connected to a given signal if the signal has at least as many arguments as the slot, and there is an implicit conversion between the types of the corresponding arguments in the signal and the slot. Example: QLabel *label = new QLabel; QLineEdit *lineEdit = new QLineEdit; QObject::connect(lineEdit, &QLineEdit::textChanged, label, &QLabel::setText); This example ensures that the label always displays the current line edit text. A signal can be connected to many slots and signals. Many signals can be connected to one slot. If a signal is connected to several slots, the slots are activated in the same order as the order the connection was made, when the signal is emitted The function returns an handle to a connection if it successfully connects the signal to the slot. The Connection handle will be invalid if it cannot create the connection, for example, if QObject is unable to verify the existence of signal (if it was not declared as a signal) You can check if the QMetaObject::Connection is valid by casting it to a bool. By default, a signal is emitted for every connection you make; two signals are emitted for duplicate connections. You can break all of these connections with a single disconnect() call. If you pass the Qt::UniqueConnection type, the connection will only be made if it is not a duplicate. If there is already a duplicate (exact same signal to the exact same slot on the same objects), the connection will fail and connect will return an invalid QMetaObject::Connection. The optional type parameter describes the type of connection to establish. In particular, it determines whether a particular signal is delivered to a slot immediately or queued for delivery at a later time. If the signal is queued, the parameters must be of types that are known to Qt's meta-object system, because Qt needs to copy the arguments to store them in an event behind the scenes. If you try to use a queued connection and get the error message QObject::connect: Cannot queue arguments of type 'MyType' (Make sure 'MyType' is registered using qRegisterMetaType().) make sure to declare the argument type with Q_DECLARE_METATYPE Overloaded functions can be resolved with help of qOverload. Note: The number of arguments variadic templates. Note: This function is thread-safe [static] QMetaObject::Connection QObject::connect(const QObject *sender, PointerToMemberFunction signal, Functor functor) This function overloads connect(). Creates a connection from signal in sender object to functor, and returns a handle to the connection The signal must be a function declared as a signal in the header. The slot function can be any function or functor that can be connected to the signal. A function can be connected to a given signal if the signal as at least as many argument as the slot. A functor can be connected to a signal if they have exactly the same number of arguments. There must exist implicit conversion between the types of the corresponding arguments in the signal and the slot. Example: void someFunction(); QPushButton *button = new QPushButton; QObject::connect(button, &QPushButton::clicked, someFunction); If your compiler support C++ lambda expressions, you can use them: QByteArray page = ...; QTcpSocket *socket = new QTcpSocket; socket->connectToHost(); QObject::connect(socket, &QTcpSocket::connected, [=] () { socket->write("GET " + page + "\r\n"); }); The connection will automatically disconnect if the sender is destroyed. However, you should take care that any objects used within the functor are still alive when the signal is emitted. Overloaded functions can be resolved with help of qOverload. Note: If the compiler does not support C++ variadic templates, the number of arguments , and the functor object must not have an overloaded or templated operator(). Note: This function is thread-safe [static] QMetaObject::Connection QObject::connect(const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type = Qt::AutoConnection) This function overloads connect(). Creates a connection of a given type from signal in sender object to functor to be placed in a specific event loop of context, and returns a handle to the connection The signal must be a function declared as a signal in the header. The slot function can be any function or functor that can be connected to the signal. A function can be connected to a given signal if the signal as at least as many argument as the slot. A functor can be connected to a signal if they have exactly the same number of arguments. There must exist implicit conversion between the types of the corresponding arguments in the signal and the slot. Example: void someFunction(); QPushButton *button = new QPushButton; QObject::connect(button, &QPushButton::clicked, this, someFunction, Qt::QueuedConnection); If your compiler support C++ lambda expressions, you can use them: QByteArray page = ...; QTcpSocket *socket = new QTcpSocket; socket->connectToHost(); QObject::connect(socket, &QTcpSocket::connected, this, [=] () { socket->write("GET " + page + "\r\n"); }, Qt::AutoConnection); The connection will automatically disconnect if the sender or the context is destroyed. However, you should take care that any objects used within the functor are still alive when the signal is emitted. Overloaded functions can be resolved with help of qOverload. Note: If the compiler does not support C++ variadic templates, the number of arguments , and the functor object must not have an overloaded or templated operator(). Note: This function is thread-safe This function was introduced in Qt 5.2. [virtual protected] void QObject::connectNotify(const QMetaMethod &signal) This virtual function is called when something has been connected to signal in this object. If you want to compare signal with a specific signal, you can use QMetaMethod::fromSignal() as follows: if (signal == QMetaMethod::fromSignal(&MyObject::valueChanged)) { // signal is valueChanged } Warning: This function violates the object-oriented principle of modularity. However, it might be useful when you need to perform expensive initialization only if something is connected to a signal. Warning: This function is called from the thread which performs the connection, which may be a different thread from the thread in which this object lives. This function was introduced in Qt 5.0. See also connect() and disconnectNotify(). [virtual protected] void QObject::customEvent(QEvent *event) This event handler can be reimplemented in a subclass to receive custom events. Custom events are user-defined events with a type value at least as large as the QEvent::User item of the QEvent::Type enum, and is typically a QEvent subclass. The event is passed in the event parameter. See also event() and QEvent. [slot] void QObject::deleteLater() Schedules this object for deletion. The object will be deleted when control returns to the event loop. If the event loop is not running when this function is called (e.g. deleteLater() is called on an object before QCoreApplication::exec()), the object will be deleted once the event loop is started. If deleteLater() is called after the main event loop has stopped, the object will not be deleted. Since Qt 4.8, if deleteLater() is called on an object that lives in a thread with no running event loop, the object will be destroyed when the thread finishes. Note that entering and leaving a new event loop (e.g., by opening a modal dialog) will not perform the deferred deletion; for the object to be deleted, the control must return to the event loop from which deleteLater() was called. Note: It is safe to call this function more than once; when the first deferred deletion event is delivered, any pending events for the object are removed from the event queue. See also destroyed() and QPointer. [signal] void QObject::destroyed(QObject *obj = Q_NULLPTR) This signal is emitted immediately before the object obj is destroyed, and can not be blocked. All the objects's children are destroyed immediately after this signal is emitted. See also deleteLater() and QPointer. [static] bool QObject::disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method) Disconnects signal in object sender from method in object receiver. Returns true if the connection is successfully broken; otherwise returns false. A signal-slot connection is removed when either of the objects involved are destroyed. disconnect() is typically used in three ways, as the following examples demonstrate. Disconnect everything connected to an object's signals: disconnect(myObject, , , ); equivalent to the non-static overloaded function myObject->disconnect(); Disconnect everything connected to a specific signal: disconnect(myObject, SIGNAL(mySignal()), , ); equivalent to the non-static overloaded function myObject->disconnect(SIGNAL(mySignal())); Disconnect a specific receiver: disconnect(myObject, , myReceiver, ); equivalent to the non-static overloaded function myObject->disconnect(myReceiver); may be used as a wildcard, meaning "any signal", "any receiving object", or "any slot in the receiving object", respectively. The sender may never be . (You cannot disconnect signals from more than one object in a single call.) If signal , it disconnects receiver and method from any signal. If not, only the specified signal is disconnected. If receiver , it disconnects anything connected to signal. If not, slots in objects other than receiver are not disconnected. If method , it disconnects anything that if receiver is left out, so you cannot disconnect a specifically-named slot on all objects. Note: This function is thread-safe See also connect(). [static] bool QObject::disconnect(const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) Disconnects signal in object sender from method in object receiver. Returns true if the connection is successfully broken; otherwise returns false. This function provides the same possibilities like disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method) but uses QMetaMethod to represent the signal and the method to be disconnected. Additionally this function returnsfalse and no signals and slots disconnected if: signal is not a member of sender class or one of its parent classes. method is not a member of receiver class or one of its parent classes. signal instance represents not a signal. QMetaMethod() may be used can be used . This function was introduced in Qt 4.8. See also disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method). bool QObject::disconnect(const char *signal = Q_NULLPTR, const QObject *receiver = Q_NULLPTR, const char *method = Q_NULLPTR) const This function overloads disconnect(). Disconnects signal from method of receiver. A signal-slot connection is removed when either of the objects involved are destroyed. Note: This function is thread-safe bool QObject::disconnect(const QObject *receiver, const char *method = Q_NULLPTR) const This function overloads disconnect(). Disconnects all signals in this object from receiver's method. A signal-slot connection is removed when either of the objects involved are destroyed. [static] bool QObject::disconnect(const QMetaObject::Connection &connection) Disconnect a connection. If the connection is invalid or has already been disconnected, do nothing and return false. See also connect(). [static] bool QObject::disconnect(const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method) This function overloads diconnect(). Disconnects signal in object sender from method in object receiver. Returns true if the connection is successfully broken; otherwise returns false. A signal-slot connection is removed when either of the objects involved are destroyed. disconnect() is typically used in three ways, as the following examples demonstrate. Disconnect everything connected to an object's signals: disconnect(myObject, , , ); Disconnect everything connected to a specific signal: disconnect(myObject, &MyObject::mySignal(), , ); Disconnect a specific receiver: disconnect(myObject, , myReceiver, ); Disconnect a connection from one specific signal to a specific slot: QObject::disconnect(lineEdit, &QLineEdit::textChanged, label, &QLabel::setText); may be used as a wildcard, meaning "any signal", "any receiving object", or "any slot in the receiving object", respectively. The sender may never be . (You cannot disconnect signals from more than one object in a single call.) If signal , it disconnects receiver and method from any signal. If not, only the specified signal is disconnected. If receiver , it disconnects anything connected to signal. If not, slots in objects other than receiver are not disconnected. If method , it disconnects anything that if receiver is left out, so you cannot disconnect a specifically-named slot on all objects. Note: It is not possible to use this overload to diconnect signals connected to functors or lambda expressions. That is because it is not possible to compare them. Instead, use the overload that takes a QMetaObject::Connection Note: This function is thread-safe See also connect(). [virtual protected] void QObject::disconnectNotify(const QMetaMethod &signal) This virtual function is called when something has been disconnected from signal in this object. See connectNotify() for an example of how to compare signal with a specific signal. If all signals were disconnected ), disconnectNotify() is only called once, and the signal will be an invalid QMetaMethod (QMetaMethod::isValid() returns false). Warning: This function violates the object-oriented principle of modularity. However, it might be useful for optimizing access to expensive resources. Warning: This function is called from the thread which performs the disconnection, which may be a different thread from the thread in which this object lives. This function may also be called with a QObject internal mutex locked. It is therefore not allowed to re-enter any of any QObject functions from your reimplementation and if you lock a mutex in your reimplementation, make sure that you don't call QObject functions with that mutex held in other places or it will result in a deadlock. This function was introduced in Qt 5.0. See also disconnect() and connectNotify(). void QObject::dumpObjectInfo() Dumps information about signal connections, etc. for this object to the debug output. This function is useful for debugging, but does nothing if the library has been compiled in release mode (i.e. without debugging information). See also dumpObjectTree(). void QObject::dumpObjectTree() Dumps a tree of children to the debug output. This function is useful for debugging, but does nothing if the library has been compiled in release mode (i.e. without debugging information). See also dumpObjectInfo(). QList<QByteArray> QObject::dynamicPropertyNames() const Returns the names of all properties that were dynamically added to the object using setProperty(). This function was introduced in Qt 4.2. [virtual] bool QObject::event(QEvent *e) This virtual function receives events to an object and should return true if the event e was recognized and processed. The event() function can be reimplemented to customize the behavior of an object. Make sure you call the parent event class implementation for all the events you did not handle. Example: class MyClass : public QWidget { Q_OBJECT public: MyClass(QWidget *parent = ); ~MyClass(); bool event(QEvent* ev) { if (ev->type() == QEvent::PolishRequest) { // overwrite handling of PolishRequest if any doThings(); return true; } else if (ev->type() == QEvent::Show) { // complement handling of Show if any doThings2(); QWidget::event(ev); return true; } // Make sure the rest of events are handled return QWidget::event(ev); } }; See also installEventFilter(), timerEvent(), QCoreApplication::sendEvent(), and QCoreApplication::postEvent(). [virtual] bool QObject::eventFilter(QObject *watched, QEvent *event) Filters events if this object has been installed as an event filter for the watched object. In your reimplementation of this function, if you want to filter the event out, i.e. stop it being handled further, return true; otherwise return false. Example: class MainWindow : public QMainWindow { public: MainWindow(); protected: bool eventFilter(QObject *obj, QEvent *ev); private: QTextEdit *textEdit; }; MainWindow::MainWindow() { textEdit = new QTextEdit; setCentralWidget(textEdit); textEdit->installEventFilter(this); } bool MainWindow::eventFilter(QObject *obj, QEvent *event) { if (obj == textEdit) { if (event->type() == QEvent::KeyPress) { QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event); qDebug() << "Ate key press" << keyEvent->key(); return true; } else { return false; } } else { // pass the event on to the parent class return QMainWindow::eventFilter(obj, event); } } Notice in the example above that unhandled events are passed to the base class's eventFilter() function, since the base class might have reimplemented eventFilter() for its own internal purposes. Warning: If you delete the receiver object in this function, be sure to return true. Otherwise, Qt will forward the event to the deleted object and the program might crash. See also installEventFilter(). T QObject::findChild(const QString &name = QString(), Qt::FindChildOptions options = Qt::FindChildrenRecursively) const Returns the child of if there is no such object. Omitting the name argument causes all object names to be matched. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly. If there is more than one child matching the search, the most direct ancestor is returned. If there are several direct ancestors, it is undefined which one will be returned. In that case, findChildren() should be used. This example returns a child QPushButton of parentWidget named "button1", even if the button isn't a direct child of the parent: QPushButton *button = parentWidget->findChild<QPushButton *>("button1"); This example returns a QListWidget child of parentWidget: QListWidget *list = parentWidget->findChild<QListWidget *>(); This example returns a child QPushButton of parentWidget (its direct parent) named "button1": QPushButton *button = parentWidget->findChild<QPushButton *>("button1", Qt::FindDirectChildrenOnly); This example returns a QListWidget child of parentWidget, its direct parent: QListWidget *list = parentWidget->findChild<QListWidget *>(QString(), Qt::FindDirectChildrenOnly); See also findChildren(). QList<T> QObject::findChildren(const QString &name = QString(), Qt::FindChildOptions options = Qt::FindChildrenRecursively) const Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. Omitting the name argument causes all object names to be matched. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly. The following example shows how to find a list of child QWidgets of the specified parentWidget named widgetname: QList<QWidget *> widgets = parentWidget.findChildren<QWidget *>("widgetname"); This example returns all QPushButtons that are children of parentWidget: QList<QPushButton *> allPButtons = parentWidget.findChildren<QPushButton *>(); This example returns all QPushButtons that are immediate children of parentWidget: QList<QPushButton *> childButtons = parentWidget.findChildren<QPushButton *>(QString(), Qt::FindDirectChildrenOnly); See also findChild(). QList<T> QObject::findChildren(const QRegExp ®Exp, Qt::FindChildOptions options = Qt::FindChildrenRecursively) const This function overloads findChildren(). Returns the children of this object that can be cast to type T and that have names matching the regular expression regExp, or an empty list if there are no such objects. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly. QList<T> QObject::findChildren(const QRegularExpression &re, Qt::FindChildOptions options = Qt::FindChildrenRecursively) const This function overloads findChildren(). Returns the children of this object that can be cast to type T and that have names matching the regular expression re, or an empty list if there are no such objects. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly. This function was introduced in Qt 5.0. bool QObject::inherits(const char *className) const Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. A class is considered to inherit itself. Example: QTimer *timer = new QTimer; // QTimer inherits QObject timer->inherits("QTimer"); // returns true timer->inherits("QObject"); // returns true timer->inherits("QAbstractButton"); // returns false // QVBoxLayout inherits QObject and QLayoutItem QVBoxLayout *layout = new QVBoxLayout; layout->inherits("QObject"); // returns true layout->inherits("QLayoutItem"); // returns true (even though QLayoutItem is not a QObject) If you need to determine whether an object is an instance of a particular class for the purpose of casting it, consider using qobject_cast<Type *>(object) instead. See also metaObject() and qobject_cast(). void QObject::installEventFilter(QObject *filterObj) Installs an event filter filterObj on this object. For example: monitoredObj->installEventFilter(filterObj); An event filter is an object that receives all events that are sent to this object. The filter can either stop the event or forward it to this object. The event filter filterObj receives events via its eventFilter() function. The eventFilter() function must return true if the event should be filtered, (i.e. stopped); otherwise it must return false. If multiple event filters are installed on a single object, the filter that was installed last is activated first. Here's a KeyPressEater class that eats the key presses of its monitored objects: class KeyPressEater : public QObject { Q_OBJECT ... protected: bool eventFilter(QObject *obj, QEvent *event); }; bool KeyPressEater::eventFilter(QObject *obj, QEvent *event) { if (event->type() == QEvent::KeyPress) { QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); qDebug("Ate key press %d", keyEvent->key()); return true; } else { // standard event processing return QObject::eventFilter(obj, event); } } And here's how to install it on two widgets: KeyPressEater *keyPressEater = new KeyPressEater(this); QPushButton *pushButton = new QPushButton(this); QListView *listView = new QListView(this); pushButton->installEventFilter(keyPressEater); listView->installEventFilter(keyPressEater); The QShortcut class, for example, uses this technique to intercept shortcut key presses. Warning: If you delete the receiver object in your eventFilter() function, be sure to return true. If you return false, Qt sends the event to the deleted object and the program will crash. Note that the filtering object must be in the same thread as this object. If filterObj is in a different thread, this function does nothing. If either filterObj or this object are moved to a different thread after calling this function, the event filter will not be called until both objects have the same thread affinity again (it is not removed). See also removeEventFilter(), eventFilter(), and event(). [protected] bool QObject::isSignalConnected(const QMetaMethod &signal) const Returns true if the signal is connected to at least one receiver, otherwise returns false. signal must be a signal member of this object, otherwise the behaviour is undefined. static const QMetaMethod valueChangedSignal = QMetaMethod::fromSignal(&MyObject::valueChanged); if (isSignalConnected(valueChangedSignal)) { QByteArray data; data = get_the_value(); // expensive operation emit valueChanged(data); } As the code snippet above illustrates, you can use this function to avoid emitting a signal that nobody listens to. Warning: This function violates the object-oriented principle of modularity. However, it might be useful when you need to perform expensive initialization only if something is connected to a signal. This function was introduced in Qt 5.0. bool QObject::isWidgetType() const Returns true if the object is a widget; otherwise returns false. Calling this function is equivalent to calling inherits("QWidget"), except that it is much faster. bool QObject::isWindowType() const Returns true if the object is a window; otherwise returns false. Calling this function is equivalent to calling inherits("QWindow"), except that it is much faster. void QObject::killTimer(int id) Kills the timer with timer identifier, id. The timer identifier is returned by startTimer() when a timer event is started. See also timerEvent() and startTimer(). [virtual] const QMetaObject *QObject::metaObject() const Returns a pointer to the meta-object of this object. A meta-object contains information about a class that inherits QObject, e.g. class name, superclass name, properties, signals and slots. Every QObject subclass that contains the Q_OBJECT macro will have a meta-object. The meta-object information is required by the signal/slot connection mechanism and the property system. The inherits() function also makes use of the meta-object. If you have no pointer to an actual object instance but still want to access the meta-object of a class, you can use staticMetaObject. Example: QObject *obj = new QPushButton; obj->metaObject()->className(); // returns "QPushButton" QPushButton::staticMetaObject.className(); // returns "QPushButton" See also staticMetaObject. void QObject::moveToThread(QThread *targetThread) Changes the thread affinity for this object and its children. The object cannot be moved if it has a parent. Event processing will continue in the targetThread. To move an object to the main thread, use QApplication::instance() to retrieve a pointer to the current application, and then use QApplication::thread() to retrieve the thread in which the application lives. For example: myObject->moveToThread(QApplication::instance()->thread()); If targetThread is zero, all event processing for this object and its children stops. Note that all active timers for the object will be reset. The timers are first stopped in the current thread and restarted (with the same interval) in the targetThread. As a result, constantly moving an object between threads can postpone timer events indefinitely. A QEvent::ThreadChange event is sent to this object just before the thread affinity is changed. You can handle this event to perform any special processing. Note that any new events that are posted to this object will be handled in the targetThread. Warning: This function is not thread-safe; the current thread must be same as the current thread affinity. In other words, this function can only "push" an object from the current thread to another thread, it cannot "pull" an object from any arbitrary thread to the current thread. See also thread(). [signal] void QObject::objectNameChanged(const QString &objectName) This signal is emitted after the object's name has been changed. The new object name is passed as objectName. Note: This is a private signal. It can be used in signal connections but cannot be emitted by the user. Note: Notifier signal for property objectName. See also QObject::objectName. QObject *QObject::parent() const Returns a pointer to the parent object. See also setParent() and children(). QVariant QObject::property(const char *name) const Returns the value of the object's name property. If no such property exists, the returned variant is invalid. Information about all available properties is provided through the metaObject() and dynamicPropertyNames(). See also setProperty(), QVariant::isValid(), metaObject(), and dynamicPropertyNames(). [protected] int QObject::receivers(const char *signal) const Returns the number of receivers connected to the signal. Since both slots and signals can be used as receivers for signals, and the same connections can be made many times, the number of receivers is the same as the number of connections made from this signal. When calling this function, you can use the SIGNAL() macro to pass a specific signal: ) { QByteArray data; get_the_value(&data); // expensive operation emit valueChanged(data); } Warning: This function violates the object-oriented principle of modularity. However, it might be useful when you need to perform expensive initialization only if something is connected to a signal. See also isSignalConnected(). void QObject::removeEventFilter(QObject *obj) Removes an event filter object obj from this object. The request is ignored if such an event filter has not been installed. All event filters for this object are automatically removed when this object is destroyed. It is always safe to remove an event filter, even during event filter activation (i.e. from the eventFilter() function). See also installEventFilter(), eventFilter(), and event(). [protected] QObject *QObject::sender() const Returns a pointer to the . The pointer is valid only during the execution of the slot that calls this function from this object's thread context. The pointer returned by this function becomes invalid if the sender is destroyed, or if the slot is disconnected from the sender's signal. Warning: This function violates the object-oriented principle of modularity. However, getting access to the sender might be useful when many signals are connected to a single slot. Warning: As mentioned above, the return value of this function is not valid when the slot is called via a Qt::DirectConnection from a thread different from this object's thread. Do not use this function in this type of scenario. See also senderSignalIndex() and QSignalMapper. [protected] int QObject::senderSignalIndex() const Returns the meta-method index of the signal that called the currently executing slot, which is returned. For signals with ) will have two different indexes (with and without the parameter), but this function will always return the index with a parameter. This does not apply when overloading signals with different parameters. Warning: This function violates the object-oriented principle of modularity. However, getting access to the signal index might be useful when many signals are connected to a single slot. Warning: The return value of this function is not valid when the slot is called via a Qt::DirectConnection from a thread different from this object's thread. Do not use this function in this type of scenario. This function was introduced in Qt 4.8. See also sender(), QMetaObject::indexOfSignal(), and QMetaObject::method(). void QObject::setParent(QObject *parent) Makes the object a child of parent. See also parent() and children(). bool QObject::setProperty(const char *name, const QVariant &value) Sets the value of the object's name property to value. If the property is defined in the class using Q_PROPERTY then true is returned on success and false otherwise. If the property is not defined using Q_PROPERTY, and therefore not listed in the meta-object, it is added as a dynamic property and false is returned. Information about all available properties is provided through the metaObject() and dynamicPropertyNames(). Dynamic properties can be queried again using property() and can be removed by setting the property value to an invalid QVariant. Changing the value of a dynamic property causes a QDynamicPropertyChangeEvent to be sent to the object. Note: Dynamic properties starting with "_q_" are reserved for internal purposes. See also property(), metaObject(), dynamicPropertyNames(), and QMetaProperty::write(). bool QObject::signalsBlocked() const Returns true if signals are blocked; otherwise returns false. Signals are not blocked by default. See also blockSignals() and QSignalBlocker. int QObject::startTimer(int interval, Qt::TimerType timerType = Qt::CoarseTimer) Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. A timer , then the timer event occurs once every time there are no more window system events to process. The virtual timerEvent() function is called with the QTimerEvent event parameter class when a timer event occurs. Reimplement this function to get timer events. If multiple timers are running, the QTimerEvent::timerId() can be used to find out which timer was activated. Example: class MyObject : public QObject { Q_OBJECT public: MyObject(QObject *parent = ); protected: void timerEvent(QTimerEvent *event); }; MyObject::MyObject(QObject *parent) : QObject(parent) { startTimer(); // 50-millisecond timer startTimer(); // 1-second timer startTimer(); // 1-minute timer } void MyObject::timerEvent(QTimerEvent *event) { qDebug() << "Timer ID:" << event->timerId(); } Note that QTimer's accuracy depends on the underlying operating system and hardware. The timerType argument allows you to customize the accuracy of the timer. See Qt::TimerType for information on the different timer types. Most platforms support an accuracy of 20 milliseconds; some provide more. If Qt is unable to deliver the requested number of timer events, it will silently discard some. The QTimer class provides a high-level programming interface with single-shot timers and timer signals instead of events. There is also a QBasicTimer class that is more lightweight than QTimer and less clumsy than using timer IDs directly. See also timerEvent(), killTimer(), and QTimer::singleShot(). QThread *QObject::thread() const Returns the thread in which the object lives. See also moveToThread(). [virtual protected] void QObject::timerEvent(QTimerEvent *event) This event handler can be reimplemented in a subclass to receive timer events for the object. QTimer provides a higher-level interface to the timer functionality, and also more general information about timers. The timer event is passed in the event parameter. See also startTimer(), killTimer(), and event(). [) Returns a translated version of sourceText, optionally based on a disambiguation string and value of n for strings containing plurals; otherwise returns QString::fromUtf8(sourceText) if no appropriate translated string is available. Example: void MainWindow::createActions() { QMenu *fileMenu = menuBar()->addMenu(tr("&File")); ... If the same sourceText by default). In Qt 4.4 and earlier, this was the preferred way to pass comments to translators. Example: MyWindow::MyWindow() { QLabel *senderLabel = new QLabel(tr("Name:")); QLabel *recipientLabel = new QLabel(tr("Name:", "recipient")); ... See Writing Source Code for Translation for a detailed description of Qt's translation mechanisms in general, and the Disambiguation section for information on disambiguation. Warning: This method is reentrant only if all translators are installed before calling this method. Installing or removing translators while performing translations is not supported. Doing so will probably result in crashes or other undesirable behavior. See also QCoreApplication::translate() and Internationalization with Qt. Member Variable Documentation const QMetaObject QObject::staticMetaObject This variable stores the meta-object for the class. A meta-object contains information about a class that inherits QObject, e.g. class name, superclass name, properties, signals and slots. Every class that contains the Q_OBJECT macro will also have a meta-object. The meta-object information is required by the signal/slot connection mechanism and the property system. The inherits() function also makes use of the meta-object. If you have a pointer to an object, you can use metaObject() to retrieve the meta-object associated with that object. Example: QPushButton::staticMetaObject.className(); // returns "QPushButton" QObject *obj = new QPushButton; obj->metaObject()->className(); // returns "QPushButton" See also metaObject(). Related Non-Members typedef QObjectList Synonym for QList<QObject *>. QList<T> qFindChildren(const QObject *obj, const QRegExp ®Exp) This function overloads qFindChildren(). This function is equivalent to obj->findChildren<T>(regExp). Note: This function was provided which did not support member template functions. It is advised to use the other form in new code. See also QObject::findChildren(). T qobject_cast(QObject *object) Returns the given . If then it will also . The class T must inherit (directly or indirectly) QObject and be declared with the Q_OBJECT macro. A class is considered to inherit itself. Example: QObject *obj = new QTimer; // QTimer inherits QObject QTimer *timer = qobject_cast<QTimer *>(obj); // timer == (QObject *)obj QAbstractButton *button = qobject_cast<QAbstractButton *>(obj); // button == 0 The qobject_cast() function behaves similarly to the standard C++ dynamic_cast(), with the advantages that it doesn't require RTTI support and it works across dynamic library boundaries. qobject_cast() can also be used in conjunction with interfaces; see the Plug & Paint example for details. Warning: If T isn't declared with the Q_OBJECT macro, this function's return value is undefined. See also QObject::inherits(). Macro Documentation Q_CLASSINFO(Name, Value) This macro associates extra information to the class, which is available using QObject::metaObject(). Qt makes only limited use of this feature, in the Active Qt, Qt D-Bus and Qt QML. The extra information takes the form of a Name string and a Value literal string. Example: class MyClass : public QObject { Q_OBJECT Q_CLASSINFO("Author", "Pierre Gendron") Q_CLASSINFO("URL", "http://www.my-organization.qc.ca") public: ... }; See also QMetaObject::classInfo(), QAxFactory, Using Qt D-Bus Adaptors, and Extending QML. Q_DISABLE_COPY(Class) Disables the use of copy constructors and assignment operators for the given Class. Instances of subclasses of QObject should not be thought of as values that can be copied or assigned, but as unique identities. This means that when you create your own subclass of QObject (director or indirect), you should not give it a copy constructor or an assignment operator. However, it may not enough to simply omit them from your class, because, if you mistakenly write some code that requires a copy constructor or an assignment operator (it's easy to do), your compiler will thoughtfully create it for you. You must do more. The curious user will have seen that the Qt classes derived from QObject typically include this macro in a private section: class MyClass : public QObject { private: Q_DISABLE_COPY(MyClass) }; It declares a copy constructor and an assignment operator in the private section, so that if you use them by mistake, the compiler will report an error. class MyClass : public QObject { private: MyClass(const MyClass &); MyClass &operator=(const MyClass &); }; But even this might not catch absolutely every case. You might be tempted to do something like this: QWidget w = QWidget(); First of all, don't do that. Most compilers will generate code that uses the copy constructor, so the privacy violation error will be reported, but your C++ compiler is not required to generate code for this statement in a specific way. It could generate code using neither the copy constructor nor the assignment operator we made private. In that case, no error would be reported, but your application would probably crash when you called a member function of w. Q_EMIT Use this macro to replace the emit keyword for emitting signals, when you want to use Qt Signals and Slots with a 3rd party signal/slot mechanism. The macro is normally used when no_keywords is specified with the CONFIG variable in the .pro file, but it can be used even when no_keywords is not specified. Q_ENUM(...) This macro registers an enum type with the meta-object system. It must be placed after the enum declaration in a class that has the Q_OBJECT or the Q_GADGET macro. For example: class MyClass : public QObject { Q_OBJECT public: MyClass(QObject *parent = ); ~MyClass(); enum Priority { High, Low, VeryHigh, VeryLow }; Q_ENUM(Priority) void setPriority(Priority priority); Priority priority() const; }; Enumerations that are declared with Q_ENUM have their QMetaEnum registered in the enclosing QMetaObject. You can also use QMetaEnum::fromType() to get the QMetaEnum. Registered enumerations are automatically registered also to the Qt meta type system, making them known to QMetaType without the need to use Q_DECLARE_METATYPE(). This will enable useful features; for example, if used in a QVariant, you can convert them to strings. Likewise, passing them to QDebug will print out their names. This function was introduced in Qt 5.5. See also Qt's Property System. Q_FLAG(...) This macro registers a single flags types with the meta-object system. It is typically used in a class definition to declare that values of a given enum can be used as flags and combined using the bitwise OR operator. The macro must be placed after the enum declaration. For example, in QLibrary, the LoadHints flag is declared in the following way: class QLibrary : public QObject { Q_OBJECT public: ... enum LoadHint { ResolveAllSymbolsHint = 0x01, ExportExternalSymbolsHint = 0x02, LoadArchiveMemberHint = 0x04 }; Q_DECLARE_FLAGS(LoadHints, LoadHint) Q_FLAG(LoadHints) ... } The declaration of the flags themselves is performed in the public section of the QLibrary class itself, using the Q_DECLARE_FLAGS() macro. Note: The Q_FLAG macro takes care of registering individual flag values with the meta-object system, so it is unnecessary to use Q_ENUM() in addition to this macro. This function was introduced in Qt 5.5. See also Qt's Property System. Q_GADGET The Q_GADGET macro is a lighter version of the Q_OBJECT macro for classes that do not inherit from QObject but still want to use some of the reflection capabilities offered by QMetaObject. Just like the Q_OBJECT macro, it must appear in the private section of a class definition. Q_GADGETs can have Q_ENUM, Q_PROPERTY and Q_INVOKABLE, but they cannot have signals or slots Q_GADGET makes a class member, staticMetaObject, available. staticMetaObject is of type QMetaObject and provides access to the enums declared with Q_ENUMS. Q_INTERFACES(...) This macro tells Qt which interfaces the class implements. This is used when implementing plugins. Example: class BasicToolsPlugin : public QObject, public BrushInterface, public ShapeInterface, public FilterInterface { Q_OBJECT Q_PLUGIN_METADATA(IID "org.qt-project.Qt.Examples.PlugAndPaint.BrushInterface" FILE "basictools.json") Q_INTERFACES(BrushInterface ShapeInterface FilterInterface) public: ... }; See the Plug & Paint Basic Tools example for details. See also Q_DECLARE_INTERFACE(), Q_PLUGIN_METADATA(), and How to Create Qt Plugins. Q_INVOKABLE Apply this macro to declarations of member functions to allow them to be invoked via the meta-object system. The macro is written before the return type, as shown in the following example: class Window : public QWidget { Q_OBJECT public: Window(); void normalMethod(); Q_INVOKABLE void invokableMethod(); }; The invokableMethod() function is marked up using Q_INVOKABLE, causing it to be registered with the meta-object system and enabling it to be invoked using QMetaObject::invokeMethod(). Since normalMethod() function is not registered in this way, it cannot be invoked using QMetaObject::invokeMethod(). Q_OBJECT The Q_OBJECT macro must appear in the private section of a class definition that declares its own signals and slots or that uses other services provided by Qt's meta-object system. For example: #include <QObject> class Counter : public QObject { Q_OBJECT public: Counter() { m_value = ; } int value() const { return m_value; } public slots: void setValue(int value); signals: void valueChanged(int newValue); private: int m_value; }; Note: This macro requires the class to be a subclass of QObject. Use Q_GADGET instead of Q_OBJECT to enable the meta object system's support for enums in a class that is not a QObject subclass. See also Meta-Object System, Signals and Slots, and Qt's Property System. Q_PROPERTY(...) This macro is used for declaring properties in classes that inherit QObject. Properties behave like class data members, but they have additional features accessible through the Meta-Object System. Q_PROPERTY(type name (READ getFunction [WRITE setFunction] | MEMBER memberName [(READ getFunction | WRITE setFunction)]) [RESET resetFunction] [NOTIFY notifySignal] [REVISION int] [DESIGNABLE bool] [SCRIPTABLE bool] [STORED bool] [USER bool] [CONSTANT] [FINAL]) The property name and type and the READ function are required. The type can be any type supported by QVariant, or it can be a user-defined type. The other items are optional, but a WRITE function is common. The attributes default to true except USER, which defaults to false. For example: Q_PROPERTY(QString title READ title WRITE setTitle USER true) For more details about how to use this macro, and a more detailed example of its use, see the discussion on Qt's Property System. See also Qt's Property System. Q_REVISION Apply this macro to declarations of member functions to tag them with a revision number in the meta-object system. The macro is written before the return type, as shown in the following example: class Window : public QWidget { Q_OBJECT Q_PROPERTY(int normalProperty READ normalProperty) Q_PROPERTY() public: Window(); int normalProperty(); int newProperty(); public slots: void normalMethod(); Q_REVISION() void newMethod(); }; This is useful when using the meta-object system to dynamically expose objects to another API, as you can match the version expected by multiple versions of the other API. Consider the following simplified example: Window window; ; const QMetaObject *windowMetaObject = window.metaObject(); ; i < windowMetaObject->methodCount(); i++) if (windowMetaObject->method(i).revision() <= expectedRevision) exposeMethod(windowMetaObject->method(i)); ; i < windowMetaObject->propertyCount(); i++) if (windowMetaObject->property(i).revision() <= expectedRevision) exposeProperty(windowMetaObject->property(i)); Using the same Window or greater. Since all methods are considered to be ) is invalid and ignored. This tag is not used by the meta-object system itself. Currently this is only used by the QtQml module. For a more generic string tag, see QMetaMethod::tag() See also QMetaMethod::revision(). Q_SET_OBJECT_NAME(Object) This macro assigns Object the objectName "Object". It doesn't matter whether Object is a pointer or not, the macro figures that out by itself. This function was introduced in Qt 5.0. See also QObject::objectName(). Q_SIGNAL This is an additional macro that allows you to mark a single function as a signal. It can be quite useful, especially when you use a 3rd-party source code parser which doesn't understand a signals or Q_SIGNALS groups. Use this macro to replace the signals keyword in class declarations, when you want to use Qt Signals and Slots with a 3rd party signal/slot mechanism. The macro is normally used when no_keywords is specified with the CONFIG variable in the .pro file, but it can be used even when no_keywords is not specified. Q_SIGNALS Use this macro to replace the signals keyword in class declarations, when you want to use Qt Signals and Slots with a 3rd party signal/slot mechanism. The macro is normally used when no_keywords is specified with the CONFIG variable in the .pro file, but it can be used even when no_keywords is not specified. Q_SLOT This is an additional macro that allows you to mark a single function as a slot. It can be quite useful, especially when you use a 3rd-party source code parser which doesn't understand a slots or Q_SLOTS groups. Use this macro to replace the slots keyword in class declarations, when you want to use Qt Signals and Slots with a 3rd party signal/slot mechanism. The macro is normally used when no_keywords is specified with the CONFIG variable in the .pro file, but it can be used even when no_keywords is not specified. Q_SLOTS Use this macro to replace the slots keyword in class declarations, when you want to use Qt Signals and Slots with a 3rd party signal/slot mechanism. The macro is normally used when no_keywords is specified with the CONFIG variable in the .pro file, but it can be used even when no_keywords is not specified. ? The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners. Download Start for Free Qt for Application Development Qt for Device Creation Qt Open Source Terms & Conditions Licensing FAQ Product Qt in Use Qt for Application Development Qt for Device Creation Commercial Features Qt Creator IDE Qt Quick Services Technology Evaluation Proof of Concept Design & Implementation Productization Qt Training Partner Network Developers Documentation Examples & Tutorials Development Tools Wiki Forums Contribute to Qt About us Training & Events Resource Center News Careers Locations Contact Us Qt MerchandiseSign InFeedback? The Qt Company
//337.out.txt -- 输出数据 单词表总数: 单词频率最高: the 次数: 所有单词为: 单词数为: ! Search: Go Reference<deque>deque Not logged registerlog template : <deque> ? std::deque < T, Alloc = allocator<T> > deque; Double ended queue deque (usually pronounced like an irregular acronym of queue. Double-ended queues are sequence containers with dynamic sizes that can be expanded or contracted on both ends (either its front back). Specific libraries may implement deques different ways, generally some form array. But any they allow the individual elements to accessed directly through random access iterators, storage handled automatically by expanding and contracting container needed. Therefore, provide a functionality similar vectors, but efficient insertion deletion also at beginning sequence, not only end. But, unlike guaranteed store all contiguous locations: accessing offsetting pointer another element causes undefined behavior. Both vectors very used purposes, internally work quite ways: While use single array needs occasionally reallocated growth, scattered chunks storage, keeping necessary information direct constant time uniform sequential (through iterators). little more complex than allows them grow efficiently under certain circumstances, especially sequences, reallocations become expensive. For operations involve frequent removals positions other end, perform worse have less consistent iterators references lists forward lists. Container properties Sequence Elements ordered strict linear sequence. Individual their position Dynamic Generally implemented array, it provides relatively fast addition/removal end Allocator-aware The uses allocator dynamically handle needs. Template parameters T Type elements. Aliased member type deque::value_type. define allocation model. By used, which defines simplest memory model value-independent. deque::allocator_type. Member types C++98C++ definition notes value_type first parameter (T) allocator_type second (Alloc) defaults to: allocator<value_type> reference allocator_type::reference allocator: value_type& const_reference allocator_type::const_reference allocator_type::pointer value_type* const_pointer allocator_type::const_pointer iterator convertible const_iterator reverse_iterator reverse_iterator<iterator> const_reverse_iterator reverse_iterator<const_iterator> difference_type signed integral type, identical iterator_traits<iterator>::difference_type usually same ptrdiff_t size_type unsigned represent non-negative value size_t functions (constructor) Construct ( function ) (destructor) Deque destructor Assign content Iterators: begin Return rbegin reverse rend cbegin cend crbegin crend Capacity: size max_size maximum resize Change empty Test whether shrink_to_fit Shrink fit Element access: Access back last Modifiers: assign push_back Add push_front Insert pop_back Delete pop_front insert erase Erase swap Swap clear Clear emplace emplace_front emplace_back Allocator: get_allocator Get Non-member overloads relational operators Relational (function Exchanges contents two C++ Information Tutorials Reference Articles Forum C library: Containers: <array> <forward_list> <list> <map> <queue> < <stack> <unordered_map> <unordered_set> <vector> Input/Output: Multi-threading: Other: deque::deque deque::~deque functions: deque::assign deque::at deque::back deque::begin deque::cbegin deque::cend deque::clear deque::crbegin deque::crend deque::emplace deque::emplace_back deque::emplace_front deque::empty deque::end deque::erase deque::front deque::get_allocator deque::insert deque::max_size deque:: deque:: deque::pop_back deque::pop_front deque::push_back deque::push_front deque::rbegin deque::rend deque::resize deque::shrink_to_fit deque::size deque::swap non-member overloads: (deque) Home page | Privacy policy cplusplus.com, - - All rights reserved v3. Spotted error? contact us Download Device Creation Application Development Services Developers Wiki Documentation Bug Reports Code Review Qt Licensing Contents Purchasing Sales Licenses Used Additional Classes QML Types Modules Creator Manual Getting Started What's 2 New Examples Supported Platforms Overviews Tools User Interfaces Core Internals Data Storage Multimedia Networking Connectivity Graphics Mobile APIs Applications available licensing options designed accommodate our various users: licensed commercial licenses appropriate development proprietary/commercial software you want share source code third parties otherwise cannot comply terms GNU LGPL version . Lesser General Public License (LGPL) applications provided conditions (or GPL ). Note: Some specific parts (modules) framework , (GPL) instead. See details. documentation Free (FDL) published Software Foundation. Alternatively, accordance contained written agreement between Company. http://qt.io/licensing/ 1 overview licensing. To purchase license, visit http://www.qt.io/download/. 1 further assistance about licensing, sales; see http://www.qt.io/locations/ 1 following table incorporate well modules license license. Third-party supplied alongside listed. Cross-module dependencies described general level. depend Core. Module/Tool Component Description Notes QSegfaultHandler Parts implementation BSD-style QUrl Implementation QUrl::fromUserInput(). Modified BSD Cocoa Platform Plugin OS X port. qtmain library A helper writing cross-platform main() Windows. Windows Shift-JIS Text Codec character encoding Japanese. ISO--JP (JIS) widely EUC-JP variable-width three Japanese standards. EUC-KR TextCodec Extended Unix (EUC) multibyte system primarily Japanese, Korean, simplified Chinese. GBK extension GB2312 Chinese characters, mainland China. Big5 Big5, BIG-, method Traditional characters. Big5-HKSCS TSCII codec conversion Tamil encoding. Stack-less Just-In-Time compiler platform-independent JIT compiler. codecs Unicode data. Permissive, GPL-compatible Macros building files CMake Qt. PCRE regular expression pattern matching syntax semantics Perl . Android Run-time run-time (libstdc++) Android. GPLv3 exception forkfd tool facilitate spawning sub-processes. MIT systems FreeBSD strtoll strtoull Functions converting integer. V8 strings doubles. MD4 implements message-digest algorithm. MD5 Mesa llvmpipe rasterizer backend (opengl32sw.dll) builds. SHA- encryption SHA- zlib purpose data compression library. Suffix List list known Internet suffixes. Mozilla Gui QKeyMapper Internal key mapping. Custom, Linux/X11 QImage smooth scaling QImage::transformed(). FreeType project font rendering. GPLv2, Project HarfBuzz OpenType layout engine. PNG Library reducing effort takes support format. Pixman low-level pixel manipulation features such image compositing trapezoid rasterization. Drag Drop Allows users transfer within applications. ANGLE Opensource map OpenGL ES API calls DirectX API. Location Poly2Tri sweepline constrained Delaunay Polygon Triangulation Library. FFTReal Fast Fourier transform real-valued arrays. (Used example code). Canvas 3D three.js JavaScript code) Three.js Loader parser loading models JSON structures. gl-matrix.js High performance matrix vector SVG arc handling module. Depends Gui, Widgets Quick Easing Equations collection swappable add flavor motion. QML, Network Controls Native Style Apache Script (Provided compatibility) benchmark tests Script. Sunspider JavaScriptCore v2 Testlib BSD, Valgrind analysis detecting leaks. valgrind.h Callgrind profiling tool. Print Support PDF Licensing. Wayland Protocol WebEngine v3 + Chromium LGPLv2., BSL, Apache, APSL, MIT, MPL, others Designer recursive shadow casting algorithm Designer. (MIT) Botan crypto Creator. Image Formats JasPer coding images. TIFF libtiff (a library) files. MNG decoding displaying format WebP SQL SQLite self-contained, embeddable, zero-configuration database XML Patterns Bison Parser generator. assimp Open Asset Import Plugins JPEG decompression. IAccessible2 An accessibility Microsoft Cycle CPU tick counter. callgrind.h xcb language binding Window System. at-spi at-spi2 toolkit-neutral way providing facilities application. xkbcommon Keymap toolkits window systems. Clucene high-performance, full-featured text search engine C++. LGPL/Apache licenses: Charts Visualization Virtual Keyboard Lipi Toolkit open toolkit online Handwriting Recognition (HWR). MIT-Style OpenWnn IME Pinyin Standard input. tcime traditional IME. 2D Renderer EGL Headers These headers based specification. SGI OpenKODE Header header Qml Macro Assembler assembly generated JIT. documents below related documents, Trademark Provides additional Contributions Files contributions Apple, Inc. Fonts Embedded Linux fonts Details restrictions PDF-related trademarks. Source Describes Third-Party third-party Trademarks trademarks owned Company organizations. Ltd. included herein copyrights respective owners. logos Finland and/or countries worldwide. property Start Terms & Conditions FAQ Product Use Commercial Features IDE Technology Evaluation Proof Concept Design Productization Training Partner Forums Contribute About Events Resource Center News Careers Locations Contact Us MerchandiseSign InFeedback? QObject Properties Slots Signals Static Members Protected Related Non-Members Detailed Thread Affinity No Copy Constructor Assignment Operator Auto-Connection Internationalization (I18n) Class objects. More... Header: #include <QObject> qmake: QT += core Instantiated By: QtObject Inherited Q3DObject, Q3DScene, Q3DTheme, QAbstract3DAxis, QAbstract3DInputHandler, QAbstract3DSeries, QAbstractAnimation, QAbstractAxis, QAbstractDataProxy, QAbstractEventDispatcher, QAbstractItemDelegate, QAbstractItemModel, QAbstractMessageHandler, QAbstractNetworkCache, QAbstractSeries, QAbstractState, QAbstractTextDocumentLayout, QAbstractTransition, QAbstractUriResolver, QAbstractVideoFilter, QAbstractVideoSurface, QAccessiblePlugin, QAction, QActionGroup, QAudioInput, QAudioOutput, QAudioProbe, QAxFactory, QAxObject, QAxScript, QAxScriptManager, QBarSet, QBluetoothDeviceDiscoveryAgent, QBluetoothLocalDevice, QBluetoothServer, QBluetoothServiceDiscoveryAgent, QBluetoothTransferManager, QBluetoothTransferReply, QBoxSet, QButtonGroup, QCameraExposure, QCameraFocus, QCameraImageCapture, QCameraImageProcessing, QCanBus, QCanBusDevice, QClipboard, QCompleter, QCoreApplication, QCustom3DItem, QDataWidgetMapper, QDBusAbstractAdaptor, QDBusAbstractInterface, QDBusPendingCallWatcher, QDBusServer, QDBusServiceWatcher, QDBusVirtualObject, QDesignerFormEditorInterface, QDesignerFormWindowManagerInterface, QDnsLookup, QDrag, QEventLoop, QExtensionFactory, QExtensionManager, QFileSelector, QFileSystemWatcher, QGamepad, QGenericPlugin, QGeoAreaMonitorSource, QGeoCodeReply, QGeoCodingManager, QGeoCodingManagerEngine, QGeoPositionInfoSource, QGeoRouteReply, QGeoRoutingManager, QGeoRoutingManagerEngine, QGeoSatelliteInfoSource, QGeoServiceProvider, QGesture, QGLShader, QGLShaderProgram, QGraphicsAnchor, QGraphicsEffect, QGraphicsItemAnimation, QGraphicsObject, QGraphicsScene, QGraphicsTransform, QHelpEngineCore, QHelpSearchEngine, QHttpMultiPart, QIconEnginePlugin, QImageIOPlugin, QInAppProduct, QInAppStore, QInAppTransaction, QInputMethod, QIODevice, QItemSelectionModel, QJSEngine, QLayout, QLegendMarker, QLibrary, QLocalServer, QLowEnergyController, QLowEnergyService, QMacToolBar, QMacToolBarItem, QMaskGenerator, QMediaControl, QMediaObject, QMediaPlaylist, QMediaRecorder, QMediaService, QMediaServiceProviderPlugin, QMimeData, QModbusDevice, QModbusReply, QMovie, QNearFieldManager, QNearFieldShareManager, QNearFieldShareTarget, QNearFieldTarget, QNetworkAccessManager, QNetworkConfigurationManager, QNetworkCookieJar, QNetworkSession, QObjectCleanupHandler, QOffscreenSurface, QOpenGLContext, QOpenGLContextGroup, QOpenGLDebugLogger, QOpenGLShader, QOpenGLShaderProgram, QOpenGLTimeMonitor, QOpenGLTimerQuery, QOpenGLVertexArrayObject, QPdfWriter, QPictureFormatPlugin, QPieSlice, QPlaceManager, QPlaceManagerEngine, QPlaceReply, QPlatformGraphicsBuffer, QPlatformSystemTrayIcon, QPluginLoader, QQmlComponent, QQmlContext, QQmlExpression, QQmlExtensionPlugin, QQmlFileSelector, QQmlNdefRecord, QQmlPropertyMap, QQuickImageResponse, QQuickItem, QQuickItemGrabResult, QQuickRenderControl, QQuickTextDocument, QQuickTextureFactory, QQuickWebEngineProfile, QRadioData, QScreen, QScriptEngine, QScriptEngineDebugger, QScriptExtensionPlugin, QScroller, QScxmlDataModel, QScxmlStateMachine, QSensor, QSensorBackend, QSensorGesture, QSensorGestureManager, QSensorGestureRecognizer, QSensorReading, QSessionManager, QSettings, QSGAbstractRenderer, QSGEngine, QSGTexture, QSGTextureProvider, QSharedMemory, QShortcut, QSignalMapper, QSignalSpy, QSocketNotifier, QSound, QSoundEffect, QSqlDriver, QSqlDriverPlugin, QStyle, QStyleHints, QStylePlugin, QSvgRenderer, QSyntaxHighlighter, QSystemTrayIcon, Qt3DCore::QAbstractAspect, Qt3DCore::QAspectEngine, Qt3DCore::QNode, Qt3DCore::Quick::QQmlAspectEngine, Qt3DInput::QKeyEvent, Qt3DInput::QMouseEvent, Qt3DInput::QWheelEvent, Qt3DRender::QGraphicsApiFilter, Qt3DRender::QPickEvent, Qt3DRender::QTextureWrapMode, QTcpServer, QTextDocument, QTextObject, QThread, QThreadPool, QTimeLine, QTimer, QTranslator, QtVirtualKeyboard::InputContext, QtVirtualKeyboard::InputEngine, QtVirtualKeyboard::ShiftHandler, QUiLoader, QUndoGroup, QUndoStack, QValidator, QValue3DAxisFormatter, QVideoProbe, QWaylandClient, QWaylandSurfaceGrabber, QWaylandView, QWebChannel, QWebChannelAbstractTransport, QWebEngineCookieStore, QWebEngineDownloadItem, QWebEnginePage, QWebEngineProfile, QWebEngineUrlRequestInterceptor, QWebEngineUrlRequestJob, QWebEngineUrlSchemeHandler, QWebSocket, QWebSocketServer, QWidget, QWindow, QWinEventNotifier, QWinJumpList, QWinTaskbarButton, QWinTaskbarProgress, QWinThumbnailToolBar, QWinThumbnailToolButton members, including inherited members Obsolete reentrant. thread-safe: connect( *sender, *signal, *receiver, *method, Qt::ConnectionType type) PointerToMemberFunction signal, method, Functor functor) *context, functor, disconnect( *method) method) objectName QString QObject(QObject *parent Q_NULLPTR) ~QObject() blockSignals( block) QObjectList children() QMetaObject::Connection Qt::AutoConnection) *signal Q_NULLPTR, *receiver *method dumpObjectInfo() dumpObjectTree() QList<QByteArray> dynamicPropertyNames() *e) eventFilter(QObject *watched, QEvent * findChild( &name QString(), Qt::FindChildOptions Qt::FindChildrenRecursively) QList<T> findChildren( QRegExp ®Exp, QRegularExpression &re, inherits( *className) installEventFilter(QObject *filterObj) isWidgetType() isWindowType() killTimer( id) QMetaObject * metaObject() moveToThread(QThread *targetThread) objectName() parent() QVariant property( *name) removeEventFilter(QObject *obj) setObjectName( &name) setParent(QObject *parent) setProperty( *name, &value) signalsBlocked() startTimer( interval, Qt::TimerType timerType Qt::CoarseTimer) QThread thread() deleteLater() destroyed(QObject *obj objectNameChanged( &objectName) QMetaMethod &signal, &method, &method) &connection) staticMetaObject tr( *sourceText, *disambiguation n -) childEvent(QChildEvent connectNotify( &signal) customEvent(QEvent disconnectNotify( isSignalConnected( receivers( *signal) sender() senderSignalIndex() timerEvent(QTimerEvent typedef qFindChildren( *obj, ®Exp) qobject_cast(QObject * Q_CLASSINFO(Name, Value) Q_DISABLE_COPY(Class) Q_EMIT Q_ENUM(...) Q_FLAG(...) Q_GADGET Q_INTERFACES(...) Q_INVOKABLE Q_OBJECT Q_PROPERTY(...) Q_REVISION Q_SET_OBJECT_NAME(Object) Q_SIGNAL Q_SIGNALS Q_SLOT Q_SLOTS heart Object Model. central feature powerful mechanism seamless communication called signals slots. You connect signal slot connect() destroy connection disconnect(). avoid never ending notification loops temporarily block blockSignals(). connectNotify() disconnectNotify() make possible track connections. QObjects organize themselves trees. When create parent, will itself parent's 1 list. parent ownership i.e., children destructor. look name optionally findChild() findChildren(). Every has found via corresponding (see QMetaObject::className()). determine object's 13 inherits inheritance hierarchy inherits() function. deleted, emits destroyed() signal. dangling QObjects. receive events filter installEventFilter() eventFilter() convenience handler, childEvent(), reimplemented child events. Last least, basic timer Qt; QTimer high-level timers. Notice macro mandatory signals, slots properties. need run Meta Compiler file. We strongly recommend subclasses regardless actually properties, since failure so lead exhibit strange widgets inherit QObject. returns widget. It much faster qobject_cast<QWidget *>(obj) obj->inherits( functions, e.g. children(), QObjectList. QList<QObject *>. instance said thread affinity, lives thread. receives queued posted handler If no affinity (that zero), running loop, then created. queried changed moveToThread(). must live parent. Consequently: setParent() fail involved threads. moved thread, too. moveToThread() created QThread::run(), because does QThread::run(). QObject's 1 variables children. parent-child relationship either passing child's 2 constructor, calling setParent(). Without step, remain old when called. neither copy constructor nor assignment This design. Actually, declared, section Q_DISABLE_COPY(). In fact, classes derived (direct indirect) declare reasoning discussion Identity vs Value Model page. main consequence should pointers your subclass) might tempted subclass value. example, without can't 1 stored one classes. pointers. Qt's 11 meta- As objects defined suitable names, follow simple naming convention, performed QMetaObject::connectSlotsByName() uic generates invokes enable auto-connection forms More given Using UI File Your manual. From added removed instances run-time. declared compile-time, yet advantages manipulated property() read setProperty() write them. supported Designer, standard user-created translation features, making translate application's 1 user into languages. user-visible translatable, wrapped tr() explained detail Writing Translation document. QMetaObject, QPointer, Q_DISABLE_COPY(), Trees Ownership. Property holds find (and findChild(). qDebug("MyClass::setPrecision(): 1 (%s) invalid precision %f", 1 qPrintable(objectName()), newPrecision); contains Notifier signal: [see note below] connections emitted user. QMetaObject::className(). Function QObject::QObject(QObject Constructs viewed owner. instance, dialog box OK Cancel buttons contains. destroys Setting constructs widget, top-level window. parent(), findChild(), [ QObject::~QObject() Destroys deleting disconnected, pending However, often safer rather directly. Warning: deleted. these stack sooner later program crash. holding outside still gives opportunity detect destroyed. Deleting waiting delivered cause exists currently executing. instead, loop after been it. deleteLater(). QObject::blockSignals( blocked (i.e., emitting invoke anything connected it). blocking occur. previous signalsBlocked(). Note even blocked. being buffered. QSignalBlocker. [ QObject::childEvent(QChildEvent passed parameter. QEvent::ChildAdded QEvent::ChildRemoved sent removed. cases rely QObject, QWidget. (This because, ChildAdded fully constructed, ChildRemoved destructed already). QEvent::ChildPolished polished, polished added. construction completed. guaranteed, multiple polish during execution widget's 1 constructor. every zero ChildPolished events, omitted immediately several times destruction, child, each table. &QObject::children() Returns file following: QList<QObject*> QObjectList; list, i.e. appended order changes QWidget raised lowered. widget becomes lowered findChildren(), [ QObject::connect( Creates sender receiver disconnect later. SIGNAL() SLOT() macros specifying example: QLabel *label QLabel; QScrollBar *scrollBar QScrollBar; QObject::connect(scrollBar, SIGNAL(valueChanged( label, SLOT(setNum( ensures label always displays current scroll bar contain variable type. E.g. would // 26 WRONG SIGNAL(valueChanged( value)), SLOT(setNum( value))); MyWidget { MyWidget(); signals: buttonClicked(); QPushButton *myButton; }; MyWidget::MyWidget() myButton QPushButton( connect(myButton, SIGNAL(clicked()), SIGNAL(buttonClicked())); } relays variable, makes relates MyWidget. many signals. Many slot. slots, activated were made, emitted. represents successfully connects connection, unable verify existence signatures aren't 1 compatible. check valid make; duplicate disconnect() call. pass Qt::UniqueConnection made duplicate. there already (exact exact objects), QMetaObject::Connection. optional describes establish. particular, determines particular delivery time. queued, system, arguments behind scenes. error message QObject::connect: Cannot (Make sure registered qRegisterMetaType().) call qRegisterMetaType() register before establish connection. thread-safe disconnect(), sender(), qRegisterMetaType(), Q_DECLARE_METATYPE(). Connection invalid. works specify method. was introduced type). connect(). Connects Equivalent connect(sender, emit header. least slot, Example: QLineEdit *lineEdit QLineEdit; QObject::connect(lineEdit, &QLineEdit::textChanged, &QLabel::setText); line edit text. ( signal) argument Q_DECLARE_METATYPE Overloaded resolved help qOverload. number limited C++ variadic templates. functor exactly arguments. There exist someFunction(); *button QPushButton; QObject::connect(button, &QPushButton::clicked, someFunction); lambda expressions, them: QByteArray ...; QTcpSocket *socket QTcpSocket; socket->connectToHost( ); QObject::connect(socket, &QTcpSocket::connected, [=] () socket->write("GET 2 " 2 " }); take care alive templates, , overloaded templated placed context, someFunction, Qt::QueuedConnection); }, Qt::AutoConnection); context QObject::connectNotify( something compare QMetaMethod::fromSignal() follows: (signal == QMetaMethod::fromSignal(&MyObject::valueChanged)) valueChanged violates principle modularity. useful expensive initialization performs lives. disconnectNotify(). QObject::customEvent(QEvent custom Custom user-defined large QEvent::User item QEvent::Type typically subclass. QEvent. [slot] QObject::deleteLater() Schedules deletion. deleted control loop. (e.g. QCoreApplication::exec()), once started. stopped, Since destroyed finishes. entering leaving (e.g., opening modal dialog) deferred deletion; safe once; delivered, QPointer. [signal] QObject::destroyed(QObject obj destroyed, objects's 1 QObject::disconnect( Disconnects receiver. broken; signal-slot examples demonstrate. Disconnect everything disconnect(myObject, , ); equivalent non- myObject->disconnect(); SIGNAL(mySignal()), myObject->disconnect(SIGNAL(mySignal())); receiver: myReceiver, myObject->disconnect(myReceiver); wildcard, meaning "any 9 signal", 2 receiving object", 4 respectively. . (You call.) disconnects not, specified disconnected. named left alone. specifically-named possibilities Additionally returnsfalse disconnected QMetaMethod() wildcard signal" 1 object". 2 QMetaMethod(). *method). receiver's 1 nothing diconnect(). &MyObject::mySignal(), slot: QObject::disconnect(lineEdit, overload diconnect functors expressions. That Instead, QObject::disconnectNotify( how ), once, (QMetaMethod::isValid() optimizing resources. disconnection, mutex locked. therefore allowed re-enter reimplementation reimplementation, don't 2 held places result deadlock. connectNotify(). QObject::dumpObjectInfo() Dumps connections, etc. debug output. debugging, compiled release mode (i.e. debugging information). dumpObjectTree(). QObject::dumpObjectTree() tree dumpObjectInfo(). QObject::dynamicPropertyNames() names setProperty(). QObject:: e recognized processed. customize behavior Make did handle. MyClass MyClass(QWidget ~MyClass(); ev) (ev->type() QEvent::PolishRequest) overwrite PolishRequest doThings(); QEvent::Show) complement Show doThings2(); QWidget:: rest installEventFilter(), timerEvent(), QCoreApplication::sendEvent(), QCoreApplication::postEvent(). QObject::eventFilter(QObject Filters installed watched function, stop further, MainWindow QMainWindow MainWindow(); *ev); QTextEdit *textEdit; MainWindow::MainWindow() textEdit QTextEdit; setCentralWidget(textEdit); textEdit->installEventFilter( MainWindow::eventFilter(QObject (obj textEdit) ( QEvent::KeyPress) QKeyEvent *keyEvent static_cast<QKeyEvent*>( qDebug() << "Ate 1 press" 1 keyEvent->key(); QMainWindow::eventFilter(obj, above unhandled class's 1 own purposes. Otherwise, installEventFilter(). QObject::findChild( cast name, Omitting matched. recursively, unless specifies option FindDirectChildrenOnly. search, most ancestor returned. ancestors, findChildren() used. parentWidget button isn't 2 parent: parentWidget->findChild<QPushButton *>( QListWidget parentWidget: *list parentWidget->findChild<QListWidget *>(); (its parent) *>( Qt::FindDirectChildrenOnly); parentWidget, *>(QString(), QObject::findChildren( shows QWidgets widgetname: QList<QWidget *> parentWidget.findChildren<QWidget *>( QPushButtons QList<QPushButton allPButtons parentWidget.findChildren<QPushButton immediate childButtons regExp, re, QObject::inherits( className className; considered itself. *timer QTimer; timer->inherits( timer->inherits( timer->inherits( QVBoxLayout QLayoutItem *layout QVBoxLayout; layout->inherits( layout->inherits( (even though QObject) it, consider qobject_cast<Type *>( qobject_cast(). QObject::installEventFilter(QObject Installs filterObj monitoredObj->installEventFilter(filterObj); filtered, stopped); filters first. Here's 1 KeyPressEater eats presses monitored objects: ... * KeyPressEater::eventFilter(QObject static_cast<QKeyEvent *>( qDebug("Ate 1 press %d", 1 keyEvent->key()); processing QObject::eventFilter(obj, And here's 1 install widgets: *keyPressEater KeyPressEater( *pushButton QListView *listView QListView( pushButton->installEventFilter(keyPressEater); listView->installEventFilter(keyPressEater); QShortcut technique intercept shortcut presses. sends filtering nothing. until again (it removed). removeEventFilter(), eventFilter(), [ QObject::isSignalConnected( receiver, behaviour undefined. valueChangedSignal QMetaMethod::fromSignal(&MyObject::valueChanged); (isSignalConnected(valueChangedSignal)) data; get_the_value(); operation valueChanged(data); snippet illustrates, nobody listens to. QObject::isWidgetType() widget; Calling inherits( except faster. QObject::isWindowType() window; inherits( QObject::killTimer( Kills identifier, id. identifier returned startTimer() timerEvent() startTimer(). *QObject::metaObject() superclass meta- required signal/slot system. actual staticMetaObject. obj->metaObject()->className(); QPushButton::staticMetaObject.className(); QObject::moveToThread(QThread Changes Event targetThread. move QApplication::instance() retrieve application, QApplication::thread() application myObject->moveToThread(QApplication::instance()->thread()); targetThread zero, stops. active timers reset. stopped restarted (with interval) result, constantly moving threads postpone indefinitely. QEvent::ThreadChange just changed. special processing. thread-safe; affinity. words, arbitrary thread(). QObject::objectNameChanged( objectName. QObject::objectName. *QObject::parent() children(). QObject::property( property. exists, variant dynamicPropertyNames(). setProperty(), QVariant::isValid(), metaObject(), QObject::receivers( receivers times, (receivers(SIGNAL(valueChanged(QByteArray))) ) get_the_value(&data); isSignalConnected(). QObject::removeEventFilter(QObject Removes request ignored installed. remove filter, activation function). *QObject::sender() signal; context. sender's 1 getting mentioned above, Qt::DirectConnection Do scenario. QSignalMapper. QObject::senderSignalIndex() meta-method index executing sender(). - parameters, indexes parameter), apply overloading parameters. QMetaObject::indexOfSignal(), QMetaObject::method(). QObject::setParent(QObject Makes QObject::setProperty( Sets Q_PROPERTY success otherwise. Q_PROPERTY, listed meta- setting QVariant. Changing QDynamicPropertyChangeEvent starting property(), dynamicPropertyNames(), QMetaProperty::write(). QObject::signalsBlocked() blocked; blockSignals() QObject::startTimer( Starts could start timer. occur interval milliseconds killTimer() occurs process. QTimerEvent occurs. Reimplement running, QTimerEvent::timerId() activated. MyObject MyObject(QObject MyObject::MyObject(QObject QObject(parent) startTimer(); -millisecond startTimer(); -second startTimer(); -minute MyObject::timerEvent(QTimerEvent "Timer 1 ID:" 1 QTimer's 1 accuracy depends underlying operating hardware. types. Most platforms milliseconds; more. deliver requested silently discard some. programming single-shot instead QBasicTimer lightweight clumsy IDs killTimer(), QTimer::singleShot(). *QObject::thread() QObject::timerEvent(QTimerEvent higher-level functionality, startTimer(), QObject::tr( translated sourceText, disambiguation containing plurals; QString::fromUtf8(sourceText) available. MainWindow::createActions() QMenu *fileMenu menuBar()->addMenu(tr( sourceText roles identifying ( earlier, preferred comments translators. MyWindow::MyWindow() *senderLabel QLabel(tr( *recipientLabel QLabel(tr( detailed description mechanisms general, Disambiguation disambiguation. reentrant translators Installing removing performing translations supported. Doing probably crashes undesirable QCoreApplication::translate() Variable QObject::staticMetaObject stores associated metaObject(). Synonym qFindChildren(). obj->findChildren<T>(regExp). workaround MSVC functions. advised code. QObject::findChildren(). subclass); (directly indirectly) macro. qobject_cast<QTimer *>(obj); (QObject *)obj QAbstractButton qobject_cast<QAbstractButton qobject_cast() behaves similarly dynamic_cast(), doesn't 4 require RTTI across boundaries. conjunction interfaces; Plug Paint macro, function's 1 QObject::inherits(). associates extra QObject::metaObject(). feature, Active Qt, D-Bus QML. Name literal Q_CLASSINFO( "Pierre 1 Gendron") 1 Q_CLASSINFO( QMetaObject::classInfo(), Adaptors, Extending Disables constructors Class. Instances thought values copied assigned, unique identities. means (director indirect), give enough simply omit mistakenly requires (it's 1 easy thoughtfully you. curious seen include section: Q_DISABLE_COPY(MyClass) declares section, mistake, report error. MyClass( &); & absolutely w QWidget(); First all, that. compilers generate privacy violation reported, statement way. we crash w. replace keyword 3rd party mechanism. normally no_keywords CONFIG .pro file, specified. registers declaration MyClass(QObject Priority High, Low, VeryHigh, VeryLow Q_ENUM(Priority) setPriority(Priority priority); priority() Enumerations Q_ENUM QMetaEnum enclosing QMetaObject. QMetaEnum::fromType() QMetaEnum. Registered enumerations meta QMetaType features; QVariant, convert strings. Likewise, QDebug print names. flags combined bitwise OR declaration. LoadHints flag way: QLibrary LoadHint ResolveAllSymbolsHint ExportExternalSymbolsHint LoadArchiveMemberHint Q_DECLARE_FLAGS(LoadHints, LoadHint) Q_FLAG(LoadHints) itself, Q_DECLARE_FLAGS() Q_FLAG registering unnecessary Q_ENUM() addition lighter reflection capabilities offered Just appear definition. Q_GADGETs Q_ENUM, Q_INVOKABLE, member, staticMetaObject, enums Q_ENUMS. tells interfaces implements. implementing plugins. BasicToolsPlugin BrushInterface, ShapeInterface, FilterInterface Q_PLUGIN_METADATA(IID FILE Q_INTERFACES(BrushInterface ShapeInterface FilterInterface) Basic Q_DECLARE_INTERFACE(), Q_PLUGIN_METADATA(), How Create Plugins. Apply declarations invoked shown Window(); normalMethod(); invokableMethod(); invokableMethod() marked up causing enabling QMetaObject::invokeMethod(). normalMethod() way, services Counter Counter() m_value ; value() m_value; slots: setValue( value); valueChanged( newValue); system's 1 Meta-Object System, Slots, declaring behave accessible Q_PROPERTY(type (READ getFunction [WRITE setFunction] MEMBER memberName [(READ WRITE setFunction)]) [RESET resetFunction] [NOTIFY notifySignal] [REVISION [DESIGNABLE [SCRIPTABLE [STORED [USER [CONSTANT] [FINAL]) READ required. items optional, common. attributes USER, Q_PROPERTY(QString title setTitle USER details use, tag revision Q_PROPERTY( normalProperty normalProperty) newProperty REVISION ) normalProperty(); newProperty(); Q_REVISION() newMethod(); expose API, match expected versions Consider expectedRevision *windowMetaObject window.metaObject(); ( i=; i windowMetaObject->methodCount(); i++) (windowMetaObject->method(i).revision() <= expectedRevision) exposeMethod(windowMetaObject->method(i)); windowMetaObject->propertyCount(); (windowMetaObject->property(i).revision() exposeProperty(windowMetaObject->property(i)); newMethod exposed greater. methods untagged, Q_REVISION() ignored. Currently QtQml generic tag, QMetaMethod::tag() QMetaMethod::revision(). assigns matter figures QObject::objectName(). mark useful, 3rd-party understand groups. declarations,
词频统计_输入到文件_update的更多相关文章
-
使用HDFS完成wordcount词频统计
任务需求 统计HDFS上文件的wordcount,并将统计结果输出到HDFS 功能拆解 读取HDFS文件 业务处理(词频统计) 缓存处理结果 将结果输出到HDFS 数据准备 事先往HDFS上传需要进行 ...
-
Hadoop之词频统计小实验
声明: 1)本文由我原创撰写,转载时请注明出处,侵权必究. 2)本小实验工作环境为Ubuntu操作系统,hadoop1-2-1,jdk1.8.0. 3)统计词频工作在单节点的伪分布上,至于真正实 ...
-
Python——字符串、文件操作,英文词频统计预处理
一.字符串操作: 解析身份证号:生日.性别.出生地等. 凯撒密码编码与解码 网址观察与批量生成 2.凯撒密码编码与解码 凯撒加密法的替换方法是通过排列明文和密文字母表,密文字母表示通过将明文字母表向左 ...
-
python字符串操作、文件操作,英文词频统计预处理
1.字符串操作: 解析身份证号:生日.性别.出生地等. 凯撒密码编码与解码 网址观察与批量生成 解析身份证号:生日.性别.出生地等 def function3(): print('请输入身份证号') ...
-
c#词频统计命令行程序
这里将用c#写一个关于词频统计的命令行程序. 预计时间分配:输入处理3h.词条排序打印2h.测试3h. 实际时间分配:输入处理1h.词条排序打印2h.测试3h.程序改进优化6h. 下面将讲解程序的完成 ...
-
软工结对项目之词频统计update
队友 胡展瑞 031602215 作业页面 GitHub 具体分工 111500206 赵畅:负责WordCount的升级,添加新的命令行参数支持(自定义输入输出文件,权重词频统计,词组统计等所有新功 ...
-
Python字典使用--词频统计的GUI实现
字典是针对非序列集合而提供的一种数据类型,字典中的数据是无序排列的. 字典的操作 为字典增加一项 dict[key] = value students = {"Z004":&quo ...
-
作业3-个人项目<;词频统计>;
上了一天的课,现在终于可以静下来更新我的博客了. 越来越发现,写博客是一种享受.来看看这次小林老师的“作战任务”. 词频统计 单词: 包含有4个或4个以上的字 ...
-
C语言实现词频统计——第二版
原需求 1.读取文件,文件内包可含英文字符,及常见标点,空格级换行符. 2.统计英文单词在本文件的出现次数 3.将统计结果排序 4.显示排序结果 新需求: 1.小文件输入. 为表明程序能跑 2.支持命 ...
随机推荐
-
wcf序列化大对象时报错:读取 XML 数据时,超出最大
错误为: 访问服务异常:格式化程序尝试对消息反序列化时引发异常: 尝试对参数 http://tempuri.org/ 进行反序列化时出 错: request.InnerException 消息是“反序 ...
-
C#委托理解(个人观点)
前言: 根据百度百科字面意思是:把事情托付给别人或别的机构(办理/处理), 我们就按汉字意思来理解; 再罗嗦一点通俗一点就是:当某人发生什么事情后把处理这个事情的工作托付给别人或别的机构(办理/处理) ...
-
QT中QWS的含义 (转至 宋金时的专栏
QT 编程和文档中的术语QWS的全称是Qt windows system,是QT自行开发的窗口系统,体系结构类似X Windows,是一个C/S结构,由QWS Server在物理设备上显示,由QWS ...
-
iOS 判断相机权限是否被限制,判断相机是否可以使用
判断相机权限是否被限制 需要导入 AVFoundation 类 [objc] view plain copy #import <AVFoundation/AVFoundation.h> ...
-
VS2012下基于Glut OpenGL glEdgeFlag示例程序:
glEdgeFlag (GLboolean flag)表示一个顶点是否应该被认为是多边形的一条边界边的起点.flag为GL_TRUE后面的点都被认为是边界上的点,flag为GL_FALSE则之后的点不 ...
-
C++ : 从栈和堆来理解C#中的值类型和引用类型
C++中并没有值类型和引用类型之说,标准变量或者自定义对象的存取默认是没有区别的.但如果深入地来看,就要了解C++中,管理数据的两大内存区域:栈和堆. 栈(stack)是类似于一个先进后出的抽屉.它的 ...
-
iOS中 MediaPlayer framework实现视频播放 韩俊强的博客
iOS开发中播放音乐可以使用MPMusicPlayerController类来实现,播放视频可以使用MPMoviePlayerController和MPMoviePlayerViewControlle ...
-
Vue.js最简单的代码
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...
-
TreeMap中文排序,TreeMap倒序输出排列
1.TreeMap集合倒序排列 import java.util.Comparator; /** * 比较算法的类,比较器 * @author Administrator * */ public cl ...
-
Android系统启动概要
注:Java系统服务与本地系统服务标注反了 1.Linux内核 Android系统启动时,首先通过BootLoader(系统加载器)加载Linux内核,在Linux加载启动时,首先初始化内核,再调用i ...