Fix changing tooltip via wxToolTip::SetTip() in wxQt
Update the actual tool tip used by Qt and not just the internal variable when SetTip() is called. Also implement wxToolTip::SetWindow(). Closes https://github.com/wxWidgets/wxWidgets/pull/1175
This commit is contained in:
committed by
Vadim Zeitlin
parent
3c369af2e6
commit
84fc5c1714
@@ -10,7 +10,8 @@
|
||||
|
||||
#include "wx/object.h"
|
||||
|
||||
class wxWindow;
|
||||
class WXDLLIMPEXP_FWD_CORE wxWindow;
|
||||
|
||||
class WXDLLIMPEXP_CORE wxToolTip : public wxObject
|
||||
{
|
||||
public:
|
||||
|
@@ -173,6 +173,11 @@ public:
|
||||
|
||||
virtual QScrollArea *QtGetScrollBarsContainer() const;
|
||||
|
||||
#if wxUSE_TOOLTIPS
|
||||
// applies tooltip to the widget.
|
||||
virtual void QtApplyToolTip(const wxString& text);
|
||||
#endif // wxUSE_TOOLTIPS
|
||||
|
||||
protected:
|
||||
virtual void DoGetTextExtent(const wxString& string,
|
||||
int *x, int *y,
|
||||
|
@@ -43,12 +43,16 @@
|
||||
|
||||
wxToolTip::wxToolTip(const wxString &tip)
|
||||
{
|
||||
SetTip( tip );
|
||||
m_window = NULL;
|
||||
SetTip(tip);
|
||||
}
|
||||
|
||||
void wxToolTip::SetTip(const wxString& tip)
|
||||
{
|
||||
m_text = tip;
|
||||
|
||||
if ( m_window )
|
||||
m_window->QtApplyToolTip(m_text);
|
||||
}
|
||||
|
||||
const wxString &wxToolTip::GetTip() const
|
||||
@@ -59,6 +63,7 @@ const wxString &wxToolTip::GetTip() const
|
||||
|
||||
void wxToolTip::SetWindow(wxWindow *win)
|
||||
{
|
||||
wxCHECK_RET(win != NULL, "window should not be NULL");
|
||||
m_window = win;
|
||||
wxMISSING_FUNCTION();
|
||||
m_window->QtApplyToolTip(m_text);
|
||||
}
|
||||
|
@@ -951,14 +951,22 @@ void wxWindowQt::DoMoveWindow(int x, int y, int width, int height)
|
||||
|
||||
|
||||
#if wxUSE_TOOLTIPS
|
||||
void wxWindowQt::QtApplyToolTip(const wxString& text)
|
||||
{
|
||||
GetHandle()->setToolTip(wxQtConvertString(text));
|
||||
}
|
||||
|
||||
void wxWindowQt::DoSetToolTip( wxToolTip *tip )
|
||||
{
|
||||
if ( m_tooltip == tip )
|
||||
return;
|
||||
|
||||
wxWindowBase::DoSetToolTip( tip );
|
||||
|
||||
if ( tip != NULL )
|
||||
GetHandle()->setToolTip( wxQtConvertString( tip->GetTip() ));
|
||||
if ( m_tooltip )
|
||||
m_tooltip->SetWindow(this);
|
||||
else
|
||||
GetHandle()->setToolTip( QString() );
|
||||
QtApplyToolTip(wxString());
|
||||
}
|
||||
#endif // wxUSE_TOOLTIPS
|
||||
|
||||
|
Reference in New Issue
Block a user