mardi 4 mai 2021

How to get the initial state of QSplitter

In my app i have a 2 widgets which separated by QSplitter vertically.

    m_splitterMain= new QSplitter(Qt::Horizontal);
    this->setCentralWidget(m_splitterMain);
    m_splitterMain->setHandleWidth(5);
    m_splitterMain->addWidget(m_navigationBar);
    m_splitterMain->addWidget(m_MainMdiArea);

I am using splitterMoved signal and process it after, to do some things. So this signal gets me a pos number (interger) and i am using it after for my calculation.

Qt doc

connect(m_PageNumLineEdit, &QLineEdit::returnPressed, this, &MainViewer::GotoPage);

I need to get initial state of this number, i am trying to find it in different props of QSplitter(m_splitterMain it's my object), but can not. I tried to to these things:

QSettings settings;
    settings.setValue("size", m_splitterMain->saveState());
    settings.value("size").toString();
    auto c=m_splitterMain->saveState();
    qInfo()<<"1" << c.toHex();
      qInfo()<<"2" <<  settings.value("size").toByteArray();;
    qInfo ()<< "nav bar size" << m_navigationBar->width();
    qInfo()<<m_splitterMain->sizes();
    qInfo()<< "splitter size w "<< m_splitterMain->size();
     qInfo()<< "splitter sizeHint w "<< m_splitterMain->sizeHint();

And it's returned me

1 "000000ff0000000100000002ffffffffffffffff0100000005010000000100"
2 "\x00\x00\x00\xFF\x00\x00\x00\x01\x00\x00\x00\x02\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x01\x00\x00\x00\x05\x01\x00\x00\x00\x01\x00"
nav bar size 640
(0, 0)
splitter size w  QSize(640, 480)
splitter sizeHint w  QSize(1592, 720)
splitter sizes w  (0, 0)
width  640

My value is 380. Maybe i less some prop. How i can get this number?

Aucun commentaire:

Enregistrer un commentaire