Выдвигающееся меню PyQt

98
25 марта 2022, 19:10

Возможно ли реализовать выдвигающееся меню нa Pyqt5 ?!

Пример как я хочу сделать.

33333.png:

Пример того, что пытался сделать я:

main1.py:

import sys
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.Qt import *
class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(1280, 588)
        font = QtGui.QFont()
        font.setFamily("Arial")
        MainWindow.setFont(font)
        MainWindow.setStyleSheet("background-color: rgb(75, 75, 75);")
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 32, 22))
        self.menubar.setMinimumSize(QtCore.QSize(32, 1))
        self.menubar.setMaximumSize(QtCore.QSize(32, 40))
        self.menubar.setAccessibleName("")
        self.menubar.setLayoutDirection(QtCore.Qt.LeftToRight)
        self.menubar.setAutoFillBackground(False)
        self.menubar.setStyleSheet("background-color: rgb(255, 255, 255);\n"
"color: rgb(72, 72, 72);\n"
"border-top-right-radius:5px;\n"
"border-bottom-right-radius:5px;\n"
"\n"
"")
        self.menubar.setDefaultUp(False)
        self.menubar.setNativeMenuBar(False)
        self.menubar.setObjectName("menubar")
        self.menueee = QtWidgets.QMenu(self.menubar)
        self.menueee.setGeometry(QtCore.QRect(198, 127, 439, 646))
        palette = QtGui.QPalette()
        brush = QtGui.QBrush(QtGui.QColor(72, 72, 72))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Button, brush)
        brush = QtGui.QBrush(QtGui.QColor(72, 72, 72))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Text, brush)
        brush = QtGui.QBrush(QtGui.QColor(72, 72, 72))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ButtonText, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Base, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Window, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Highlight, brush)
        brush = QtGui.QBrush(QtGui.QColor(72, 72, 72, 128))
        brush.setStyle(QtCore.Qt.NoBrush)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.PlaceholderText, brush)
        brush = QtGui.QBrush(QtGui.QColor(72, 72, 72))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Button, brush)
        brush = QtGui.QBrush(QtGui.QColor(72, 72, 72))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Text, brush)
        brush = QtGui.QBrush(QtGui.QColor(72, 72, 72))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ButtonText, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Base, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Window, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Highlight, brush)
        brush = QtGui.QBrush(QtGui.QColor(72, 72, 72, 128))
        brush.setStyle(QtCore.Qt.NoBrush)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.PlaceholderText, brush)
        brush = QtGui.QBrush(QtGui.QColor(72, 72, 72))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Button, brush)
        brush = QtGui.QBrush(QtGui.QColor(72, 72, 72))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Text, brush)
        brush = QtGui.QBrush(QtGui.QColor(72, 72, 72))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ButtonText, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Base, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Window, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Highlight, brush)
        brush = QtGui.QBrush(QtGui.QColor(72, 72, 72, 128))
        brush.setStyle(QtCore.Qt.NoBrush)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.PlaceholderText, brush)
        self.menueee.setPalette(palette)
        self.menueee.setStyleSheet("\n"
"QMenu::item {padding: 10.5px 10.5px 10.5px 6px;}\n"
"        QMenu::item::selected {      \n"
"    background-color: rgba(138, 138, 138, 20);\n"
"}\n"
"selection-background-color: transparent;")
        self.menueee.setTearOffEnabled(False)
        self.menueee.setTitle("")
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap("E:/nvuti/pngs/33333.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.menueee.setIcon(icon)
        self.menueee.setSeparatorsCollapsible(False)
        self.menueee.setToolTipsVisible(False)
        self.menueee.setObjectName("menueee")
        MainWindow.setMenuBar(self.menubar)
        self.actioneeeeeee = QtWidgets.QAction(MainWindow)
        font = QtGui.QFont()
        font.setFamily("Arial")
        font.setPointSize(14)
        font.setStyleStrategy(QtGui.QFont.PreferAntialias)
        self.actioneeeeeee.setFont(font)
        self.actioneeeeeee.setVisible(True)
        self.actioneeeeeee.setIconVisibleInMenu(False)
        self.actioneeeeeee.setObjectName("actioneeeeeee")
        self.action = QtWidgets.QAction(MainWindow)
        self.action.setObjectName("action")
        self.action_2 = QtWidgets.QAction(MainWindow)
        self.action_2.setObjectName("action_2")
        self.action_3 = QtWidgets.QAction(MainWindow)
        self.action_3.setObjectName("action_3")
        self.action_4 = QtWidgets.QAction(MainWindow)
        self.action_4.setObjectName("action_4")
        self.action_5 = QtWidgets.QAction(MainWindow)
        self.action_5.setObjectName("action_5")
        self.action_6 = QtWidgets.QAction(MainWindow)
        self.action_6.setObjectName("action_6")
        self.action_7 = QtWidgets.QAction(MainWindow)
        self.action_7.setObjectName("action_7")
        self.action_8 = QtWidgets.QAction(MainWindow)
        self.action_8.setObjectName("action_8")
        self.action_9 = QtWidgets.QAction(MainWindow)
        font = QtGui.QFont()
        font.setFamily("Arial")
        font.setPointSize(14)
        font.setStyleStrategy(QtGui.QFont.PreferAntialias)
        self.action_9.setFont(font)
        self.action_9.setIconVisibleInMenu(True)
        self.action_9.setObjectName("action_9")
        self.action_10 = QtWidgets.QAction(MainWindow)
        font = QtGui.QFont()
        font.setFamily("Arial")
        font.setPointSize(14)
        font.setStyleStrategy(QtGui.QFont.PreferAntialias)
        self.action_10.setFont(font)
        self.action_10.setIconVisibleInMenu(True)
        self.action_10.setObjectName("action_10")
        self.action_11 = QtWidgets.QAction(MainWindow)
        self.action_11.setEnabled(False)
        font = QtGui.QFont()
        font.setFamily("Arial")
        font.setPointSize(14)
        self.action_11.setFont(font)
        self.action_11.setVisible(True)
        self.action_11.setObjectName("action_11")
        self.action_12 = QtWidgets.QAction(MainWindow)
        self.action_12.setEnabled(False)
        self.action_12.setVisible(True)
        self.action_12.setObjectName("action_12")
        self.action_13 = QtWidgets.QAction(MainWindow)
        self.action_13.setEnabled(False)
        self.action_13.setVisible(True)
        self.action_13.setObjectName("action_13")
        self.action_14 = QtWidgets.QAction(MainWindow)
        self.action_14.setEnabled(False)
        self.action_14.setVisible(True)
        self.action_14.setObjectName("action_14")
        self.action_15 = QtWidgets.QAction(MainWindow)
        self.action_15.setEnabled(False)
        self.action_15.setVisible(True)
        self.action_15.setObjectName("action_15")
        self.action_16 = QtWidgets.QAction(MainWindow)
        self.action_16.setEnabled(False)
        self.action_16.setVisible(True)
        self.action_16.setObjectName("action_16")
        self.action_17 = QtWidgets.QAction(MainWindow)
        self.action_17.setEnabled(False)
        self.action_17.setVisible(True)
        self.action_17.setObjectName("action_17")
        self.action_18 = QtWidgets.QAction(MainWindow)
        self.action_18.setEnabled(False)
        self.action_18.setVisible(True)
        self.action_18.setObjectName("action_18")
        self.action_19 = QtWidgets.QAction(MainWindow)
        self.action_19.setEnabled(False)
        self.action_19.setVisible(True)
        self.action_19.setObjectName("action_19")
        self.action_20 = QtWidgets.QAction(MainWindow)
        self.action_20.setEnabled(False)
        self.action_20.setVisible(True)
        self.action_20.setObjectName("action_20")
        self.action_21 = QtWidgets.QAction(MainWindow)
        self.action_21.setEnabled(False)
        self.action_21.setVisible(True)
        self.action_21.setObjectName("action_21")
        self.action_22 = QtWidgets.QAction(MainWindow)
        self.action_22.setEnabled(False)
        self.action_22.setVisible(True)
        self.action_22.setObjectName("action_22")
        self.action_23 = QtWidgets.QAction(MainWindow)
        self.action_23.setEnabled(False)
        self.action_23.setVisible(True)
        self.action_23.setObjectName("action_23")
        self.action_24 = QtWidgets.QAction(MainWindow)
        self.action_24.setEnabled(False)
        self.action_24.setVisible(True)
        self.action_24.setObjectName("action_24")
        self.action_25 = QtWidgets.QAction(MainWindow)
        self.action_25.setEnabled(False)
        self.action_25.setVisible(True)
        self.action_25.setObjectName("action_25")
        self.action_26 = QtWidgets.QAction(MainWindow)
        self.action_26.setEnabled(False)
        self.action_26.setVisible(True)
        self.action_26.setObjectName("action_26")
        self.action_27 = QtWidgets.QAction(MainWindow)
        self.action_27.setEnabled(False)
        self.action_27.setVisible(True)
        self.action_27.setObjectName("action_27")
        self.action_28 = QtWidgets.QAction(MainWindow)
        self.action_28.setEnabled(False)
        self.action_28.setVisible(True)
        self.action_28.setObjectName("action_28")
        self.action_29 = QtWidgets.QAction(MainWindow)
        self.action_29.setEnabled(False)
        self.action_29.setVisible(True)
        self.action_29.setObjectName("action_29")
        self.action_30 = QtWidgets.QAction(MainWindow)
        self.action_30.setEnabled(False)
        self.action_30.setVisible(True)
        self.action_30.setObjectName("action_30")
        self.action_31 = QtWidgets.QAction(MainWindow)
        self.action_31.setEnabled(False)
        self.action_31.setVisible(True)
        self.action_31.setObjectName("action_31")
        self.action_32 = QtWidgets.QAction(MainWindow)
        self.action_32.setObjectName("action_32")
        self.action_33 = QtWidgets.QAction(MainWindow)
        self.action_33.setEnabled(False)
        self.action_33.setVisible(True)
        self.action_33.setObjectName("action_33")
        self.menueee.addAction(self.actioneeeeeee)
        self.menueee.addSeparator()
        self.menueee.addAction(self.action_9)
        self.menueee.addSeparator()
        self.menueee.addAction(self.action_10)
        self.menueee.addAction(self.action_11)
        self.menueee.addAction(self.action_12)
        self.menueee.addAction(self.action_13)
        self.menueee.addAction(self.action_14)
        self.menueee.addAction(self.action_15)
        self.menueee.addAction(self.action_16)
        self.menueee.addAction(self.action_17)
        self.menueee.addAction(self.action_18)
        self.menueee.addAction(self.action_19)
        self.menueee.addAction(self.action_20)
        self.menueee.addAction(self.action_21)
        self.menubar.addAction(self.menueee.menuAction())
        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)
    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
        self.actioneeeeeee.setText(_translate("MainWindow", "FAQ"))
        self.action.setText(_translate("MainWindow", "                                                                                                                    "))
        self.action_2.setText(_translate("MainWindow", "                                                                                                                    "))
        self.action_3.setText(_translate("MainWindow", "                                                                                                                    "))
        self.action_4.setText(_translate("MainWindow", "                                                                                                                    "))
        self.action_5.setText(_translate("MainWindow", "                                                                                                                    "))
        self.action_6.setText(_translate("MainWindow", "                                                                                                                    "))
        self.action_7.setText(_translate("MainWindow", "                                                                                                                    "))
        self.action_8.setText(_translate("MainWindow", "                                                                                                                    "))
        self.action_9.setText(_translate("MainWindow", "Бонус"))
        self.action_10.setText(_translate("MainWindow", "Контакты"))
        self.action_11.setText(_translate("MainWindow", "                                                                                "))
        self.action_12.setText(_translate("MainWindow", "                                                                                "))
        self.action_13.setText(_translate("MainWindow", "                                                                                "))
        self.action_14.setText(_translate("MainWindow", "                                                                                "))
        self.action_15.setText(_translate("MainWindow", "                                                                                "))
        self.action_16.setText(_translate("MainWindow", "                                                                                "))
        self.action_17.setText(_translate("MainWindow", "                                                                                "))
        self.action_18.setText(_translate("MainWindow", "                                                                                "))
        self.action_19.setText(_translate("MainWindow", "                                                                                "))
        self.action_20.setText(_translate("MainWindow", "                                                                                "))
        self.action_21.setText(_translate("MainWindow", "                                                                           "))
        self.action_22.setText(_translate("MainWindow", "                                                                                "))
        self.action_23.setText(_translate("MainWindow", "                                                                          "))
        self.action_24.setText(_translate("MainWindow", "                                                                                "))
        self.action_25.setText(_translate("MainWindow", "                                                      "))
        self.action_26.setText(_translate("MainWindow", "                                                                                "))
        self.action_27.setText(_translate("MainWindow", "                                                   "))
        self.action_28.setText(_translate("MainWindow", "                                                           "))
        self.action_29.setText(_translate("MainWindow", "                                                           "))
        self.action_30.setText(_translate("MainWindow", "                                                           "))
        self.action_31.setText(_translate("MainWindow", "                                                           "))
        self.action_32.setText(_translate("MainWindow", "                                                                                "))
        self.action_33.setText(_translate("MainWindow", "                                                                                "))

class MainApp(QtWidgets.QMainWindow, Ui_MainWindow):
    def __init__(self):
        super().__init__()
        self.setupUi(self)
if __name__=="__main__":
    app = QtWidgets.QApplication(sys.argv)
    window = MainApp()
    window.show()
    sys.exit(app.exec_())
Answer 1

Попробуйте так:

from PyQt5 import QtCore, QtWidgets, QtGui  
class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(640, 480)                    
        MainWindow.setStyleSheet("background:qlineargradient(spread:pad, x1:0.565, y1:0, x2:0.508475, y2:1, stop:0 rgba(0, 0, 103, 0), stop:1 rgba(255, 255, 255, 0));")
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setStyleSheet("")
        self.centralwidget.setObjectName("centralwidget")
        self.btnPullOut = QtWidgets.QPushButton(self.centralwidget)    
        self.btnPullOut.setGeometry(QtCore.QRect(0, 0, 31, 23))
        self.btnPullOut.setStyleSheet("QPushButton#btnPullOut{\n"
"      background:none;\n"
"      border:0px;\n"
"      }")
        self.btnPullOut.setText("")
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap("rdeyG.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.btnPullOut.setIcon(icon)
        self.btnPullOut.setObjectName("btnPullOut")
        self.frame1 = QtWidgets.QFrame(self.centralwidget)
        self.frame1.setGeometry(QtCore.QRect(0, 0, 640, 480))
        self.frame1.setStyleSheet("background:orange;")
        self.frame1.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.frame1.setFrameShadow(QtWidgets.QFrame.Raised)
        self.frame1.setObjectName("frame1")
        self.frame2 = QtWidgets.QFrame(self.centralwidget)
        self.frame2.setGeometry(QtCore.QRect(0, 0, 0, 480))
        self.frame2.setStyleSheet("background:red;")
        self.frame2.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.frame2.setFrameShadow(QtWidgets.QFrame.Raised)
        self.frame2.setObjectName("frame2")
        self.btnPullOut.raise_()
        MainWindow.setCentralWidget(self.centralwidget)
        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)
    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))

class ListWidget(QtWidgets.QListWidget):
    def itClicked(self, item):
        QtWidgets.QMessageBox.information(
            None, 
            "ListWidget", 
            "Вы нажали: {}".format(item.text())
        )

class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
    def __init__(self):
        super(MainWindow, self).__init__()
        self.setupUi(self)
        self.setAttribute(QtCore.Qt.WA_TranslucentBackground, True)   
        self.setAttribute(QtCore.Qt.WA_NoSystemBackground, False)      
        self.btnPullOut.setCheckable(True) 
        self.btnPullOut.click()
        self.btnPullOut.installEventFilter(self)
        self.listWidget = ListWidget()     
        self.listWidget.addItems(["Item 1", "Item 2", "Item 3", "Item 4", ])
        self.listWidget.itemClicked.connect(self.listWidget.itClicked)
        lay = QtWidgets.QVBoxLayout(self.frame2)
        lay.addWidget(self.listWidget)
        lay.setContentsMargins(0, 20, 0, 0)
        self._animation = QtCore.QPropertyAnimation(self.frame2, b'size', self)
        self._animation.setStartValue(QtCore.QSize(0, self.height()))
        self._animation.setEndValue(QtCore.QSize(121, self.height()))
        self._animation.setDuration(200)
    def eventFilter(self, watched, event):
        if self.btnPullOut is watched:
            if event.type() == 2 and self.btnPullOut.isChecked(): 
                self._animation.setDirection(QtCore.QAbstractAnimation.Forward)
                self._animation.start()
            if event.type() == 2 and (not self.btnPullOut.isChecked()):
                self._animation.setDirection(QtCore.QAbstractAnimation.Backward)
                self._animation.start()
        return super(MainWindow,self).eventFilter(watched, event)

Stylesheet = '''
QListWidget {
    color: white;
}
QListWidget::item:selected {
    background: rgb(172, 172, 172);
}
'''

if __name__ == '__main__':
    import sys
    app = QtWidgets.QApplication(sys.argv)
    app.setStyleSheet(Stylesheet)
    app.setFont(QtGui.QFont("Times", 12, QtGui.QFont.Bold))
    p = MainWindow()  
    p.show()
    sys.exit(app.exec_())

Answer 2

Брал код из своего проекта. Уверен, что можно лучше, так что жду критики.

.h file:

#include <QWidget>
#include <QPropertyAnimation>
#include <QObject>
#include <QString>
#include <QPushButton>

class SlideMenu: public QWidget
{
    Q_OBJECT
public:
    SlideMenu(QWidget *parent = nullptr);
    void setDuration(const int dur);
    bool isOpen() const;
public slots:
    void openMenu();
    void closeMenu();
    void setUpState();
private:
    QPropertyAnimation *openAnimation = new QPropertyAnimation(this, "geometry");
    QPropertyAnimation *closeAnimation = new QPropertyAnimation(this, "geometry");
    bool isOpenMenu = false;
    bool isStarted = false;
};

.cpp file:

SlideMenu::SlideMenu(QWidget *parent):
    QWidget(parent)
{
    connect(openAnimation, &QPropertyAnimation::finished, this, [this](){
        isStarted = false;
    });
    connect(closeAnimation, &QPropertyAnimation::finished, this, [this](){
        isStarted = false;
    });
    connect(closeAnimation, &QPropertyAnimation::finished, this, &QWidget::hide);
    setDuration(150);
    hide();
}
void SlideMenu::openMenu()
{
    show();
    isOpenMenu = true;
    openAnimation->setStartValue(QRect(-width(), y(), width(), height()));
    openAnimation->setEndValue(QRect(0, y(), width(), height()));
    openAnimation->start();
    isStarted = true;
}
void SlideMenu::closeMenu()
{
    if(isOpenMenu && !isStarted) {
        show();
        isOpenMenu = false;
        closeAnimation->setStartValue(QRect(0, y(), width(), height()));
        closeAnimation->setEndValue(QRect(-width(), y(), width(), height()));
        closeAnimation->start();
        isStarted = true;
    }
}
void SlideMenu::setUpState()
{
    if(!isStarted) {
        if(!isOpenMenu)
            openMenu();
        else
            closeMenu();
    }
}
void SlideMenu::setDuration(const int dur)
{
    openAnimation->setDuration(dur);
    closeAnimation->setDuration(dur);
}
bool SlideMenu::isOpen() const
{
    return isOpenMenu;
}

P.S. Работает только с левой стороной экрана, но легко можно изменить, а ещё лучше сделать универсальным.

READ ALSO
Слово класс в аргументе функции

Слово класс в аргументе функции

Первый раз встретил данную конструкцию, когда class в параметрах функции и не могу понять для чего оно используется?

170
Оператор in &gt;&gt; в собственном классе строк

Оператор in >> в собственном классе строк

Реализовал класс строк, и сделал оператор >> , когда ввожу строчку с пробелами , например а ааыаыв аы, то выводит только первый символ, то бишь...

106
Qt C++ фильтр для бд

Qt C++ фильтр для бд

необходимо сделать фильтр для бдЕсть поля в них нужно вписать значение, которое потом должно перейти в запрос и вывести результат в tableView

83
Добавление CURL в cmake проект | VS19 | Windows

Добавление CURL в cmake проект | VS19 | Windows

Имею следующий код в CMakeListstxt

167