Search code examples
qtsizeqtoolbar

QT - Resize QToolbar


i have some concatenate toolbar. For every toolbar i have call:

toolbar->setGeometry(x,y,width,height)

but i have no resize.

I try to call

toolbar->updateGeometry();

but nothing.

My goal is to expand every toolbar with my size definition


Solution

  • There is a good chance you are using this for repositioning your toolbars on init and saving at closing.

    Here is a solid way to do that:

    What you really need is to use the QMainWindow saveGeometry() and restoreGeometry() functions and save and load the byte array through the QSettings interface.

    writeSettings

    QSettings s;
    
    s.beginGroup("MainWindow");
    
    this->restoreGeometry(s.value("geometry").toByteArray());
    this->restoreState(s.value("windowState").toByteArray());
    
    s.endGroup();
    

    readSettings

    QSettings s;
    
    s.beginGroup("MainWindow");
    
    s.setValue("geometry", saveGeometry());
    s.setValue("windowState", saveState());
    
    s.endGroup();
    

    Hope that helps.