Hi Qt developers,
I wrote a simple Qt4 code to get a QMainWindow with Partial Transparent Background and Custom Shape..
Here the core of my application:
setMask
((new QPixmap("logoic_big.png"))->mask
());
setPalette(*palette);
setWindowFlags(Qt::FramelessWindowHint);
centralWidget->setLayout(layout);
m_showAddCommentButton->setFlat(true);
m_showAddCommentButton->setAutoFillBackground(true);
m_showAddCommentButton->setFixedSize(40,40);
QPalette palett
= m_showAddCommentButton
->palette
();
m_showAddCommentButton->setPalette(palett);
m_showAddCommentButton
->setIcon
(QIcon("exit.png"));
m_showAddCommentButton
->setIconSize
(QSize(40,
40));
m_showAddCommentButton->setToolTip("Close");
layout->addWidget(m_showAddCommentButton,0,0);
setCentralWidget(centralWidget);
connect(m_showAddCommentButton, SIGNAL(clicked()), this, SLOT(close()));
setMask((new QPixmap("logoic_big.png"))->mask());
QPalette* palette = new QPalette();
palette->setBrush(QPalette::Background,*(new QBrush(*(new QPixmap("logoic_big.png")))));
setPalette(*palette);
setWindowFlags(Qt::FramelessWindowHint);
QWidget *centralWidget = new QWidget(this);
QGridLayout *layout = new QGridLayout();
centralWidget->setLayout(layout);
QPushButton* m_showAddCommentButton = new QPushButton();
m_showAddCommentButton->setFlat(true);
m_showAddCommentButton->setAutoFillBackground(true);
m_showAddCommentButton->setFixedSize(40,40);
QPalette palett = m_showAddCommentButton->palette();
palett.setColor(QPalette::Button,QColor(Qt::transparent));
m_showAddCommentButton->setPalette(palett);
m_showAddCommentButton->setIcon(QIcon("exit.png"));
m_showAddCommentButton->setIconSize(QSize(40,40));
m_showAddCommentButton->setToolTip("Close");
layout->addWidget(m_showAddCommentButton,0,0);
setCentralWidget(centralWidget);
connect(m_showAddCommentButton, SIGNAL(clicked()), this, SLOT(close()));
To copy to clipboard, switch view to plain text mode
My question is:
How can I put buttons in a specified positon, that I like, of my custom shape QmainWindows ?
Many thanks in advance..
roby
Bookmarks