【发布时间】:2011-09-05 00:04:41
【问题描述】:
我在我的 wxWidgets 应用程序中遇到了一个非常奇怪的问题。我想要做的是使用自定义 wxPanel 资源来允许一些冗余控制并提供让我更轻松地工作的方法。在我尝试将对主框架中的资源的访问权传递给每个面板之前,此问题并未发生。
我正在做的是使用#include 将wxPanel 资源的类头包含在主类的头中。但是,当尝试声明 CopyRow 类型的资源时,它位于我包含的头文件中,我收到错误 CopyRow does not name a type
这是主类头的代码,
#ifndef CPAMOUNTMAIN_H
#define CPAMOUNTMAIN_H
//(*Headers(CPAmountFrame)
#include <wx/sizer.h>
#include <wx/stattext.h>
#include <wx/menu.h>
#include <wx/spinctrl.h>
#include <wx/statline.h>
#include "CopyRow.h"
#include <wx/panel.h>
#include <wx/frame.h>
#include <wx/statusbr.h>
//*)
class CPAmountFrame: public wxFrame
{
public:
CPAmountFrame(wxWindow* parent,wxWindowID id = -1);
void UpdateTotal();
virtual ~CPAmountFrame();
private:
//(*Handlers(CPAmountFrame)
void OnQuit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
void OntotalCopiesChange(wxSpinEvent& event);
static void CallTotalCopies();
//*)
//(*Identifiers(CPAmountFrame)
static const long ID_CUSTOM1;
static const long ID_CUSTOM2;
static const long ID_CUSTOM3;
static const long ID_CUSTOM4;
static const long ID_CUSTOM5;
static const long ID_CUSTOM6;
static const long ID_STATICLINE1;
static const long ID_STATICTEXT1;
static const long ID_SPINCTRL1;
static const long ID_STATICTEXT2;
static const long ID_PANEL1;
static const long idMenuQuit;
static const long idMenuAbout;
static const long ID_STATUSBAR1;
//*)
//(*Declarations(CPAmountFrame)
CopyRow* Custom4;
wxStaticText* totalPrice;
CopyRow* Custom1;
CopyRow* Custom5;
CopyRow* Custom2;
CopyRow* Custom3;
wxPanel* Panel1;
wxStaticText* StaticText1;
wxStatusBar* StatusBar1;
wxStaticLine* StaticLine1;
CopyRow* Custom6;
wxSpinCtrl* totalCopies;
//*)
DECLARE_EVENT_TABLE()
};
#endif // CPAMOUNTMAIN_H
这里是 CopyRow.h 的代码,
#ifndef COPYROW_H
#define COPYROW_H
#ifndef WX_PRECOMP
//(*HeadersPCH(CopyRow)
#include <wx/sizer.h>
#include <wx/stattext.h>
#include <wx/panel.h>
//*)
#endif
//(*Headers(CopyRow)
#include <wx/spinctrl.h>
//*)
#include "CPAmountMain.h"
class CopyRow: public wxPanel
{
public:
CopyRow(wxWindow* parent,const char* label,wxSpinCtrl* copies,wxWindowID id=wxID_ANY,const wxPoint& pos=wxDefaultPosition,const wxSize& size=wxDefaultSize);
void SetLabel(const char* label);
void SetPrice(double price);
void SetCounter(int value);
int GetCounter();
virtual ~CopyRow();
private:
//(*Declarations(CopyRow)
wxStaticText* copyLabel;
wxSpinCtrl* numCopies;
wxStaticText* copyPrice;
//*)
//(*Identifiers(CopyRow)
static const long ID_SPINCTRL1;
static const long ID_STATICTEXT1;
static const long ID_STATICTEXT2;
//*)
wxSpinCtrl* totalCopies;
//(*Handlers(CopyRow)
void OnnumCopiesChange(wxSpinEvent& event);
//*)
DECLARE_EVENT_TABLE()
};
#endif
谁能向我解释这个错误?我现在不知道。
【问题讨论】:
-
这是您得到的唯一错误吗?你确定它在
cpamountmain.h吗?它在哪条线上?发布错误很好,但您需要发布所有错误(如果不是唯一错误)加上错误的确切文本,而不仅仅是错误(即包括文件和行信息)。 -
@Seth 它位于主标题的第 60、62、63、64、65 和 70 行。基本上在任何地方都声明了 CopyRow 类型的东西。
-
还有其他错误吗?仔细看。