Qt で opencv を使用して、論文のビデオ認識を行っています。
だから私はメインウィンドウ(カメラとカメラの設定用のいくつかのスライダーを表示する)と、高度な設定用のスライダー付きのボタンを押すと開くダイアログウィンドウを持っています。私の問題は次のとおりです。次のようなクラスのインスタンスで作成します
Moving M;
mainwindow.cpp で、次のようなパラメーターを設定できます
M.BasicSetting1 = someValue;
しかし、別のウィンドウ (ダイアログ) で M インスタンスにアクセスして、M.AdvencedSettings を設定することはできません。
では、mainwindow.cpp と dialog.cpp の両方でパラメーターを設定するには、Moving クラスのインスタンスをどこでどのように作成する必要があるのでしょうか? 私が十分に明確であったことを願っています...おそらく、誰かがその方法のさまざまな単純な例を投稿できれば。大変お世話になりました!
これが私が持っているものです(この方法で簡単になるので、完全なコードを投稿するつもりはありません(私がする必要がないことを願っています:))
Moving.h //where my class is defined which accesses my webcam and stuff
mainwindow.h //mainwindow where it shows the video with basicsettings
dialog.h //some advanced settings for the webcam
main.cpp
Moving.cpp
Mainwindow.cpp
dialog.cpp
動く.h
class Moving
{
public:
int BasicSetting1;
int Basic Setting2;
int AdvancedSetting1;
int AdvancedSetting2;
//lots of other stuff
Moving();
~Moving();
void move(); //starts and shows the camera
};
メインウィンドウ.cpp
#include "Moving.h"
#include "mainwindow.h"
Moving M;
M.BasicSetting1 = SliderValue;
M.move(); //shows camera
//and of course lots of other stuff