Problem with WA_TranslucentBackground



  • Qt 4.7 (Win)

    Hi, I'am making custom interface for my application and use own class CImageButton for buttons and checkboxes.

    *.h file:
    @
    class CImageButton : public QLabel
    {
    Q_OBJECT
    public:
    CImageButton(QString strBasePicture, QWidget *parent = 0, Qt::WindowFlags f = 0);
    QString m_strBasePicture;
    signals:
    void clicked();
    protected:
    void enterEvent(QEvent *event);
    void leaveEvent(QEvent *event);
    void mousePressEvent(QMouseEvent *event);
    void mouseReleaseEvent(QMouseEvent *event);
    };
    @

    *.cpp file:
    @
    CImageButton::CImageButton(QString strBasePicture, QWidget *parent, Qt::WindowFlags f) : QLabel (parent, f)
    {
    m_strBasePicture = strBasePicture;
    this->setPixmap(QPixmap(m_strBasePicture+".png"));
    }

    void CImageButton::enterEvent(QEvent *event)
    {
    this->setPixmap(QPixmap(m_strBasePicture+"_active.png"));
    }

    void CImageButton::leaveEvent(QEvent *event)
    {
    this->setPixmap(QPixmap(m_strBasePicture+".png"));
    }
    void CImageButton::mousePressEvent(QMouseEvent *event)
    {
    this->setPixmap(QPixmap(m_strBasePicture+"_hold.png"));
    }
    void CImageButton::mouseReleaseEvent(QMouseEvent *event)
    {
    emit clicked();
    this->setPixmap(QPixmap(m_strBasePicture+"_active.png"));
    }
    @

    It works great, but if I minimize my window, all instances of CImageButton freeze in their last state (loaded pixmaps) and QLineEdit's too. But all functionality still exist. QLineEdit receives text, but don't display it. Buttons works to. Seems that didn't work only setPixmap method.
    If I show QMessageBox::information(...) for example, interface unfreeze and text appears. Also if I comment line
    @this->setAttribute(Qt::WA_TranslucentBackground);@
    minimize work as expected.

    @
    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);
    this->setWindowFlags(Qt::FramelessWindowHint);
    this->setAttribute(Qt::WA_TranslucentBackground);
    this->setAttribute(Qt::WA_NoSystemBackground);
    //this->setAttribute(Qt::WA_TransparentForMouseEvents);
    m_pCloseButton = new CImageButton(":/img/close_button", this);
    connect (m_pCloseButton, SIGNAL(clicked()), this, SLOT(CloseButton_clicked()));
    // ...
    }

    void MainWindow::HideButton_clicked()
    {
    this->showMinimized();
    }
    @

    Thanks in advance!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.