思路是在Qt上面布局一堆Qwidet,然后通过Qwidget的winID()传给open_window里用。
void h_open_window(const std::vector<QWidget*> &rt)
{
using namespace Halcon;
Halcon::set_check("give_error");
for (int i = 0; i < MAX_WINDOW_NUM; i++)
{
Halcon::set_check("~father");
printf("w: %d h: %d\n", (Hlong)rt[i]->width(), (Hlong)rt[i]->height());
open_window(0, 0, (Hlong)rt[i]->width(), (Hlong)rt[i]->height(), (Hlong)rt[i]->winId(), "visible", "", &hdisp_hand[i]);
}
}
//halcon显示图片用
HTuple hdisp_hand[MAX_WINDOW_NUM];
void h_disp_obj(const Halcon::Hobject & obj, const Halcon::HTuple & disp_hand)
{
try
{
Halcon::set_check("~give_error");
Hlong w, h;
Halcon::get_image_pointer1(obj, NULL, NULL, &w, &h);
Halcon::HDevWindowStack::Push(disp_hand);
Halcon::HDevWindowStack::SetActive(disp_hand);
Halcon::set_part(disp_hand, NULL, NULL, h, w);
disp_obj(obj, disp_hand);
}
catch (Halcon::HException &except)
{
Halcon::set_check("give_error");
Halcon::set_tposition(disp_hand, 0, 1);
Halcon::write_string(disp_hand, except.message);
}
}