M_pMaximizeButton->setProperty( "maximizeProperty", "maximize") M_pMaximizeButton->setProperty( "maximizeProperty", "restore") M_pMaximizeButton->setToolTip(tr( "Restore")) PWindow->isMaximized() ? pWindow->showNormal() : pWindow->showMaximized() QPushButton *pButton = qobject_cast(sender()) M_pIconLabel->setPixmap(icon.pixmap(m_pIconLabel->size())) M_pTitleLabel->setText(pWidget->windowTitle()) SendMessage( HWND(pWindow->winId()), WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0) īool TitleBar::eventFilter( QObject *obj, QEvent *event) Void TitleBar::mousePressEvent( QMouseEvent *event) Void TitleBar::mouseDoubleClickEvent( QMouseEvent *event) PLayout->setContentsMargins( 5, 0, 5, 0) Ĭonnect(m_pMinimizeButton, SIGNAL(clicked(bool)), this, SLOT(onClicked())) Ĭonnect(m_pMaximizeButton, SIGNAL(clicked(bool)), this, SLOT(onClicked())) Ĭonnect(m_pCloseButton, SIGNAL(clicked(bool)), this, SLOT(onClicked())) QHBoxLayout *pLayout = new QHBoxLayout(this) M_pMaximizeButton->setToolTip( "Maximize") M_pMinimizeButton->setToolTip( "Minimize") M_pCloseButton->setObjectName( "closeButton") M_pMaximizeButton->setObjectName( "maximizeButton") M_pMinimizeButton->setObjectName( "minimizeButton") M_pTitleLabel->setObjectName( "whiteLabel") M_pMaximizeButton->setFixedSize( 27, 22) M_pMinimizeButton->setFixedSize( 27, 22) M_pTitleLabel->setSizePolicy( QSizePolicy:: Expanding, QSizePolicy:: Fixed) M_pMaximizeButton = new QPushButton(this) M_pMinimizeButton = new QPushButton(this) Title_bar.cpp #include #include #include #include #include #include #include "title_bar.h" #ifdef Q_OS_WIN #pragma comment(lib, "user32.lib") #include #endif TitleBar:: TitleBar( QWidget *parent) minimize, maximize / restore, close operation Set the interface title and icon virtual bool eventFilter(QObject *obj, QEvent * event) Drag of mice interface virtual void mousePressEvent(QMouseEvent * event) Virtual void mouseDoubleClickEvent(QMouseEvent * event) Double-click the maximum size / restore of the title bar Title_bar.h #ifndef TITLE_BAR # define TITLE_BAR #include
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |