c++ - Qt widget on top of other non qt window -
i'm developing plugin commercial program (i can't change it) use in windows operating system. in plugin create qt widget , when in main program button clicked, qt widget appears.
my problem widget appears under main program window, while want on top of it. can stay on top, if necessary.
qt::windowstaysontophint not seems work here because have no qt parents.
i've found way put on top, following qt wiki, , i've created method call after widget constructor:
void radiationpatternwidget::setwindowtopmost() { #ifdef q_ws_win32 hwnd hwnd = winid(); dword exstyle = ::getwindowlong(hwnd, gwl_exstyle); dword style = ::getwindowlong(hwnd, gwl_style); hwnd parent = null; if (parentwidget()) { parent = parentwidget()->winid(); } exstyle |= ws_ex_topmost; hwnd newhwnd = ::createwindowex(exstyle, l"#32770", null, style, cw_usedefault, cw_usedefault, cw_usedefault, cw_usedefault, parent, null, qwinappinst(), null); create(newhwnd, true, true); #endif // q_ws_win32 }
then call after constructor:
m_pxradiationpatternwidget = new radiationpatternwidget(); m_pxradiationpatternwidget->setwindowtopmost();
now stays on top, i've problem:
- inside widget use qpushbutton cannot , if window raised not clickable. clicked() signals not captured , button image not change when click on mouse.
- inside widget use derived qglwidget derived class. when put on top widget black, while if don't call method works well.
how can raise on top che qwidget correctly?
before using hack, check if widget->window()->raise()
wouldn't work.
using window class "#32770" error. need use same window class qt using window.
you need retrieve class used qt existing window, , create new window same class.
Comments
Post a Comment