Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Problem with WA_TranslucentBackground
QtWS25 Last Chance

Problem with WA_TranslucentBackground

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 2.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Shrine
    wrote on last edited by
    #1

    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!

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved