'Return the toolbox state (as a `QByteArray`).
.. note:: Individual tabs are stored by their action\'s text.'

def saveState(self):

    version = 2
    actions = map(self.tabAction, range(self.count()))
    expanded = [action for action in actions if action.isChecked()]
    expanded = [action.text() for action in expanded]
    byte_array = QByteArray()
    stream = QDataStream(byte_array, QIODevice.WriteOnly)
    stream.writeInt(version)
    stream.writeQStringList(expanded)
    return byte_array
