PDA

View Full Version : Where's QWinHost include ?



rsilva
21st April 2011, 22:45
I'm trying to use it, but, <QWinHost> <qwinhost.h> can't be found, how i can include it ?

Zlatomir
21st April 2011, 23:10
That is not part of the Qt framework, it's from Qt solutions, source can be found here (http://qt.gitorious.org/qt-solutions).

rsilva
22nd April 2011, 00:49
Thanks ^^, I'm using it, but now, with another problem.



QWidget* HotKeyDelegate::createEditor(
QWidget* parent,
const QStyleOptionViewItem& option,
const QModelIndex& index) const
{
QWidget* w = new QWidget(parent);
QGridLayout* qgl = new QGridLayout(w);
qgl->setMargin(0);
HotKeyEditor* e = new HotKeyEditor(w);
qgl->addWidget(e);
return w;
}


And, the hotkey command finally loaded, but, it's messages isn't responding
I can press any key, or click, and it's only lose focus and the TableWidget stops the editing of the cell.

Why this is happening ?

The class code:



class HotKeyEditor : public QWinHost
{
Q_OBJECT
public:
explicit HotKeyEditor(QWidget *parent = 0);
virtual ~HotKeyEditor();

protected:
virtual HWND createWindow(HWND parent, HINSTANCE instance);
};




HotKeyEditor::HotKeyEditor(QWidget *parent) :
QWinHost(parent)
{
this->resize(100, 20);
}

HotKeyEditor::~HotKeyEditor()
{
}

HWND HotKeyEditor::createWindow(HWND parent, HINSTANCE instance)
{
HWND wnd = CreateWindowExA(0, HOTKEY_CLASSA, "", WS_CHILD | WS_VISIBLE, 0, 0,
0, 0, parent, 0, instance, 0);

HFONT font = CreateFontA(14, 0, 0, 0,
FW_DONTCARE,
FALSE, FALSE, FALSE,
DEFAULT_CHARSET,
OUT_OUTLINE_PRECIS,
CLIP_DEFAULT_PRECIS,
CLEARTYPE_QUALITY,
VARIABLE_PITCH,
0);

SendMessageA(wnd, WM_SETFONT, (WPARAM)font, 0);
SendMessageA(wnd, WM_SETFOCUS, 0, 0);

return wnd;
}


EDIT:
The code works if the host is outside the delegate in TableWidget, but, i need it for editing the cell