CodePudding user response:
CvGetWindowHandleSetWindowLong
CodePudding user response:
cvGetWindowHandleCodePudding user response:
CvGetWindowHandle handle to get the cvGetWindowName unable to get the right window name, use SetWindowLong didn't also way, then I borrowed from another schemeNamedWindow (" view ", WINDOW_AUTOSIZE);
HWND HWND=(HWND) cvGetWindowHandle (" the view ");
HWND hParent=: : GetParent (HWND);
: : SetParent (hWnd, (hWnd) winId ());
: : ShowWindow (hParent, SW_HIDE);
But still can't will imshow Windows embedded in QT,,, don't know where the operation is the
CodePudding user response:
Comparison, I have reconfirm by SPY++ HWND value, there is no problem,: : SetParent (hWnd, (hWnd) winId ()); The execution is successful,
The returned handle can be: : ShowWindow (hParent, SW_HIDE); To hide,
But imshow picture is unable to display to QT interface, vomiting blood,,
Don't know what reason led to this problem,,
CodePudding user response:
@ zhao four teachers help please take a lookCodePudding user response:
HWND Whnd;
Whnd=(HWND) cvGetWindowHandle (" the view ");
If (Whnd) {
The HWND parentHwnd;
ParentHwnd=(HWND) GetWindowLong (Whnd GWL_HWNDPARENT);
If (parentHwnd) ShowWindow (parentHwnd, SW_HIDE);//hide
SetWindowLong (parentHwnd GWL_STYLE,/* WS_CLIPCHILDREN | */WS_CLIPSIBLINGS | WS_CHILDWINDOW);//hide the title bar
SetWindowLong (parentHwnd GWL_EXSTYLE, WS_EX_TOPMOST);//in front of the
If (parentHwnd) ShowWindow (parentHwnd, SW_SHOW);//show
}
CodePudding user response:
@ 4 teacher zhaoThank you for your reply, I use your code is tested, parentHwnd value is always 0, then the program is still not reach the effect, specific code is as follows:
NamedWindow (" view ", WINDOW_AUTOSIZE);
The HWND Whnd;
Whnd=(HWND) cvGetWindowHandle (" the view ");
If (Whnd)
{
The HWND parentHwnd;
ParentHwnd=(HWND) GetWindowLong (Whnd GWL_HWNDPARENT);
If (parentHwnd)
{
ShowWindow (parentHwnd, SW_HIDE);//hide
}
SetWindowLong (parentHwnd GWL_STYLE,/* WS_CLIPCHILDREN | */WS_CLIPSIBLINGS | WS_CHILDWINDOW);//hide the title bar
SetWindowLong (parentHwnd GWL_EXSTYLE, WS_EX_TOPMOST);//in front of the
If (parentHwnd)
{
ShowWindow (parentHwnd, SW_SHOW);//show
}
}
CodePudding user response:
NamedWindow (" view ", WINDOW_AUTOSIZE);
The HWND Whnd;
Whnd=(HWND) cvGetWindowHandle (" the view ");
If (Whnd)
{
The HWND parentHwnd;
ParentHwnd=(HWND) GetWindowLong (Whnd GWL_HWNDPARENT);
If (parentHwnd)
{
ShowWindow (parentHwnd, SW_HIDE);//hide
}
SetWindowLong (parentHwnd GWL_STYLE,/* WS_CLIPCHILDREN | */WS_CLIPSIBLINGS | WS_CHILDWINDOW);//hide the title bar
SetWindowLong (parentHwnd GWL_EXSTYLE, WS_EX_TOPMOST);//in front of the
If (parentHwnd)
{
ShowWindow (parentHwnd, SW_SHOW);//show
}
}
CodePudding user response:
I attached a complete code
# include "mainwindow. H"
# include "ui_mainwindow. H"
MainWindow: : MainWindow (QWidget * parent) :
QMainWindow (parent),
UI (new UI: : MainWindow)
{
The UI - & gt; SetupUi (this);
//open the camera
Bool ok=mvCapture. Open (0);
NamedWindow (" view ", WINDOW_AUTOSIZE);
The HWND Whnd;
Whnd=(HWND) cvGetWindowHandle (" the view ");
If (Whnd)
{
The HWND parentHwnd;
ParentHwnd=(HWND) GetWindowLong (Whnd GWL_HWNDPARENT);
If (parentHwnd)
{
ShowWindow (parentHwnd, SW_HIDE);//hide
}
SetWindowLong (parentHwnd GWL_STYLE,/* WS_CLIPCHILDREN | */WS_CLIPSIBLINGS | WS_CHILDWINDOW);//hide the title bar
SetWindowLong (parentHwnd GWL_EXSTYLE, WS_EX_TOPMOST);//in front of the
If (parentHwnd)
{
ShowWindow (parentHwnd, SW_SHOW);//show
}
}
QObject: : connect (& amp; DataTimer, SIGNAL (timeout ()), and this, SLOT (OnTimer ()));
DataTimer. Start (100);
//a=QWidget * QWidget: : find ((WId) hWnd1);
//UI - & gt; GridLayout - & gt; AddWidget (a);
}
MainWindow: : ~ MainWindow ()
{
Delete the UI;
}
//display timer
Void MainWindow: : OnTimer ()
{
Mat srcImage;
MvCapture> SrcImage;
Imshow (" view ", srcImage);
}
CodePudding user response:
My GWL_HWNDPARENT this parameter wave red, don't know why, the Windows header files are addedCodePudding user response:
This - & gt; The resize (600400);QWidget * QWidget=new QWidget (this);
QWidget - & gt; The resize (300300);
QWidget - & gt; To move (0, 0);
NamedWindow (" view ", WINDOW_NORMAL);
ResizeWindow (" view ", 300300);
HWND Whnd=static_cast & lt; HWND> (cvGetWindowHandle (" the view "));
QDebug () & lt;
{
HWND hParent=: : GetParent (Whnd);
QWidget: : SetParent (Whnd, (HWND) - & gt; WinId ());
: : ShowWindow (hParent, SW_HIDE);//hide to run the program frame
}
CodePudding user response:
null