#include *View类的头文件后 View类中GetDocument()出错的解决办法

博客指出在编程中,要在包含 *view 的头文件之前包含 *doc 头文件,强调了头文件包含顺序的重要性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

要在包含 *view的头文件之前包含*doc头文件
加上注释,不要分隔,写出当前的功能/**************************************************************************** ** ** This file is part of the LibreCAD project, a 2D CAD program ** ** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl) ** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. ** ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file gpl-2.0.txt included in the ** packaging of this file. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ** ** This copyright notice MUST APPEAR in all copies of the script! ** **********************************************************************/ #ifndef QC_MDIWINDOW_H #define QC_MDIWINDOW_H #include <qmainwindow.h> #include <qlist.h> #include "qc_graphicview.h" #include "qg_layerwidget.h" #include "qg_recentfiles.h" #include "qg_pentoolbar.h" //Added by qt3to4: #include <QCloseEvent> #include "rs_document.h" /** * MDI document window. Contains a document and a view (window). * * @author Andrew Mustun */ class QC_MDIWindow: public QMainWindow { Q_OBJECT public: QC_MDIWindow(RS_Document* doc, QWidget* parent, const char* name=NULL, Qt::WindowFlags wflags=Qt::WDestructiveClose); ~QC_MDIWindow(); void initDoc(RS_Document* doc=NULL); void initView(); public slots: void slotPenChanged(RS_Pen p); void slotFileNew(); bool slotFileOpen(const QString& fileName, RS2::FormatType type); bool slotFileSave(bool &cancelled, bool isAutoSave=false); bool slotFileSaveAs(bool &cancelled); bool slotFileClose(bool force); void slotFilePrint(); public: /** @return Pointer to graphic view */ QC_GraphicView* getGraphicView() { return graphicView; } /** @return Pointer to document */ RS_Document* getDocument() { return document; } /** @return Pointer to graphic or NULL */ RS_Graphic* getGraphic() { return document->getGraphic(); } /** @return Pointer to current event handler */ RS_EventHandler* getEventHandler() { if (graphicView!=NULL) { return graphicView->getEventHandler(); } else { return NULL; } } void addChildWindow(QC_MDIWindow* w); void removeChildWindow(QC_MDIWindow* w); QC_MDIWindow* getPrintPreview(); /** * Sets the parent window that will be notified if this */ void setParentWindow(QC_MDIWindow* p) { RS_DEBUG->print("setParentWindow"); parentWindow = p; } /** * @return The MDI window id. */ int getId() { return id; } bool closeMDI(bool force, bool ask=true); void setForceClosing(bool on) { forceClosing = on; } friend std::ostream& operator << (std::ostream& os, QC_MDIWindow& w); signals: void signalClosing(); protected: void closeEvent(QCloseEvent*); private: void drawChars(); private: /** window ID */ int id; /** ID counter */ static int idCounter; /** Graphic view */ QC_GraphicView* graphicView; /** Document */ RS_Document* document; /** Does the window own the document? */ bool owner; /** * List of known child windows that show blocks of the same drawing. */ QList<QC_MDIWindow*> childWindows; /** * Pointer to parent window which needs to know if this window * is closed or NULL. */ QC_MDIWindow* parentWindow; /** * If flag is set, the user will not be asked about closing this file. */ bool forceClosing; }; #endif
最新发布
07-04
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值