QDialog에서 하위 클래스 인 HWND를 읽으려고 시도하지만 NULL 포인터가 반환되는 Memory Access Error
으로 실행 중입니다. 클라이언트 코드Windows 10에서 QDialog에 대해 HWND를 얻는 방법
WId Dialog::getWindowHandle() {
WId id = this->effectiveWinId(); // debugger says id = 0
return id;
}
나는 또한 시도했다 : -
헤더 파일은 내가
는#ifndef DIALOG_H
#define DIALOG_H
#include <QDialog>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QGraphicsItem>
namespace Ui {
class Dialog;
}
class Dialog : public QDialog
{
Q_OBJECT
public:
explicit Dialog(QWidget *parent = 0);
~Dialog();
WId getWindowHandle (void);
private:
Ui::Dialog *ui;
QGraphicsScene *scene;
QGraphicsTextItem *text;
};
#endif // DIALOG_H
는 구현 ... 나는 심지어 WID를 얻을 수없는 등의 HWND를 얻으려고 노력 포기했습니다 이 :
WId Dialog::getWindowHandle() {
QWidget *parent = this->nativeParentWidget(); // debugger says parent = 0
WId id = parent->effectiveWinId(); // so this crashes
return id;
}
Qt를 처음 사용했습니다. 바라기를 내가 놓치고있는 뭔가 분명하다.
QDialog의 정보를 가져 오는 표준 방법은 무엇입니까?
툴체인 : Windows 10 주년, Qt 5.7, 모두 64 비트, Visual Studio 14 C++ 컴파일러, Windows SDK 디버거.
'this-> window() -> winId()'를 시도하십시오. –
** HWND가 필요한 대상은 무엇입니까? ** 처음에는 HWND가 있다고 가정합니까? 현대적인 UI에서는 기본 창을 사용하여 인터페이스를 빌드하지 않습니다. Qt는 그것을하지 않으며, WPF는 그것을하지 않으며, GTK는하지 않습니다. –