2017-12-07 29 views
0
#ifndef FF_H 
#define FF_H 

#include <QtQuick/QQuickPaintedItem> 
#include "qpainter.h" 
#include <QQuickItem> 
#include <QQuickWindow> 

class Draw_on_qimage : public QQuickPaintedItem 
{ 
    Q_OBJECT 
public: 
    virtual void paint(QPainter *); 
    Draw_on_qimage(QQuickPaintedItem *parent = 0); 

public slots: 
    void setbb_list(QList<bounding_box_struct> bb_list) 
    { 
     for (int h = 0; h < bb_list.size(); h++) 
     { 
      bounding_box_struct obj; 
      obj.x = bb_list[h].x; 

      m_bb_list.push_back(obj); 
     } 

     emit bb_listChanged(m_bb_list); 
    } 

protected: 
    virtual void componentComplete(); 

private: 
    struct bounding_box_struct 
    { int x; 
     int y; 
     int w; 
     int h; 
     std::string vehicle_type; 
    }; 

    Q_PROPERTY(QList<bounding_box_struct> bb_list 
       READ bb_list 
       WRITE setbb_list 
       NOTIFY bb_listChanged) 

    QList<bounding_box_struct> m_bb_list; 

signals: 
    void bb_listChanged(QList<bounding_box_struct> bb_list); 
}; 

#endif // FF_H 

bb_listは、Q_PROPERTYである必要があります。あなたはそれを使用する前に、構造体を定義する必要がありますQtのクラスで宣言された構造体を同じクラスの関数に渡すにはどうすればいいですか?

error: ‘bounding_box_struct’ was not declared in this scope 
    void setbb_list(QList<bounding_box_struct> bb_list) 
         ^
error: request for member ‘size’ in ‘bb_list’, which is of non-class type ‘int’ 
     for (int h = 0; h < bb_list.size(); h++) 
            ^

error: invalid types ‘int[int]’ for array subscript 
      obj.x = bb_list[h].x; 
          ^

答えて

3

私は、次のエラーを取得しています。それでクラスの初めに入れてください。

さらに、このタイプを使用するパブリックメソッドがある場合は、パブリックにする必要があります。詳細については、多くの

struct MyClass { 
    struct Inner {}; 
    Inner doThis(Inner i); 
    Inner doThat(Inner i) { return i; } // Not qualified 
}; 

MyClass::Inner MyClass::doThis(Inner i) { return i; } 
//^required     ^Can be qualified 
+0

おかげ:

はまた、あなたは、クラス定義の外で、あなたのメソッドの実装を置けば、あなたは完全に戻り値の型に構造体を修飾する必要がありますが、それはパラメータではオプションだということに注意してください。 –

関連する問題