修改wayland下设置窗管属性失效导致字母提示窗异常问题

This commit is contained in:
lixueman 2022-12-21 11:36:44 +08:00
parent 02d992b142
commit 7036f1b619
4 changed files with 10 additions and 27 deletions

View File

@ -28,16 +28,7 @@ LetterClassifyButton::LetterClassifyButton(QWidget *parent,
{ {
this->setFlat(true); this->setFlat(true);
m_letter = letter; m_letter = letter;
// if (m_fullscreen) { m_tooltip = new LetterToolTip(this);
// QFont font;
// font.setPixelSize(Style::LeftLetterFontSize);
// this->setFont(font);
// QPalette pe = this->palette();
// pe.setColor(QPalette::ButtonText, Qt::white);
// this->setPalette(pe);
// }
// this->setText(letter);
this->setFocusPolicy(Qt::NoFocus); this->setFocusPolicy(Qt::NoFocus);
this->setCheckable(true); this->setCheckable(true);
this->setStyleSheet("padding: 0px;"); this->setStyleSheet("padding: 0px;");
@ -147,16 +138,10 @@ void LetterClassifyButton::enterEvent(QEvent *e)
Q_UNUSED(e); Q_UNUSED(e);
if (m_fullscreen) { if (m_fullscreen) {
// QFont font;
// font.setPixelSize(Style::LeftLetterFontSize*3);
// this->setFont(font);
// this->setFixedSize(Style::LeftLetterBtnHeight*2,Style::LeftLetterBtnHeight*2);
tooltip = new LetterToolTip();
QPoint oPoint = this->mapToGlobal(QPoint(this->rect().x() + 35, this->rect().y() - 10)); QPoint oPoint = this->mapToGlobal(QPoint(this->rect().x() + 35, this->rect().y() - 10));
tooltip->setText(m_letter); m_tooltip->setText(m_letter);
tooltip->raise(); m_tooltip->move(oPoint);
tooltip->move(oPoint); m_tooltip->show();
tooltip->show();
} }
} }
@ -169,9 +154,7 @@ void LetterClassifyButton::leaveEvent(QEvent *e)
font.setPixelSize(Style::m_leftLetterFontSize); font.setPixelSize(Style::m_leftLetterFontSize);
this->setFont(font); this->setFont(font);
this->setFixedSize(Style::m_leftLetterBtnHeight, Style::m_leftLetterBtnHeight); this->setFixedSize(Style::m_leftLetterBtnHeight, Style::m_leftLetterBtnHeight);
tooltip->close(); m_tooltip->hide();
delete tooltip;
tooltip = nullptr;
} }
} }

View File

@ -37,7 +37,7 @@ public:
QString m_letter = QString(); QString m_letter = QString();
private: private:
bool m_fullscreen = false; bool m_fullscreen = false;
LetterToolTip *tooltip = nullptr; LetterToolTip *m_tooltip = nullptr;
protected: protected:
void enterEvent(QEvent *e); void enterEvent(QEvent *e);

View File

@ -21,9 +21,9 @@
#include <QHBoxLayout> #include <QHBoxLayout>
LetterToolTip::LetterToolTip(QWidget *parent): LetterToolTip::LetterToolTip(QWidget *parent):
QDialog(parent) QWidget(parent)
{ {
this->setWindowFlags(/*Qt::FramelessWindowHint *//*| */Qt::X11BypassWindowManagerHint); this->setWindowFlag(Qt::ToolTip);
this->setAttribute(Qt::WA_TranslucentBackground, true); this->setAttribute(Qt::WA_TranslucentBackground, true);
this->setContentsMargins(0, 0, 0, 0); this->setContentsMargins(0, 0, 0, 0);
this->setAutoFillBackground(false); this->setAutoFillBackground(false);

View File

@ -17,10 +17,10 @@
#ifndef LETTERTOOLTIP_H #ifndef LETTERTOOLTIP_H
#define LETTERTOOLTIP_H #define LETTERTOOLTIP_H
#include <QDialog>
#include <QLabel> #include <QLabel>
#include <QWidget>
class LetterToolTip : public QDialog class LetterToolTip : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public: