"Unable to set geometry" after removing "Qt::FramelessWindowHint"



  • Hi,
    i have a Window with some subwidgets.
    on buttonpress F10 i am toggeling the WindowFlag Qt::FramelessWindowHint.
    But every time the flag is removed the window is not resized properly and the bottom half of the text is cut away.
    also, everytime i call a function to resize the font and redraw the window i get an "unable to set geometry" error

    Has somebody encountered a similar problem or knows how to solve this?

    before
    after

    some code:

    if(e->key() == Qt::Key_F10){
                framelessToggle = !framelessToggle;
                if(framelessToggle){
                    this->setWindowFlags(this->windowFlags()|Qt::FramelessWindowHint|Qt::WindowStaysOnTopHint);
    
                } else {
                    Qt::WindowFlags flags = this->windowFlags();
                    flags ^=  Qt::FramelessWindowHint;
                    this->setWindowFlags(flags);
                }
                doLayout();
            return;
        }
    
    void Comp_Messwertanzeige::doLayout(){
        // do some layouting
        for(int i = 0; i<widgetlist->length();i++){
             widgetlist->at(i)->doLayout();
        }
    
        this->show();
        this->adjustSize();
    }
    

    the widgets in the widgetlist also use adjustSize()
    on changing the fontsize the function doLayout() is called


  • Moderators

    @Prahlhans

    1. i suggest you reset the window flags on every toggle. Meaning don't operate on the current window flags but completely reset them accordingly to your needs
    2. why don't you simply resize the window to it's sizeHint()? This should already include all the layout metrics (assuming you used QLayouts in your widgets)

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.