Qt World Summit: Submit your Presentation

Hiding parts of QDialog

  • I changed from Qt 4.8.4 to 5.0.2, when I execute my application I get a warning about setGeometry: violating constraints of window,but the code doesnt even use setGeometry. The idea is that when I click a certain button parts of my dialog should hide, and the dialog size should change to suit the needs of the remaining contents. PLEASE HELP

    Here is the code,its actually a custom slot:
    void KeyBoardDialog::showHideKeyboard(){
    ui->pushButtonHideKeyBoard->setText("Show Keyboard");

    else {
        ui->pushButtonHideKeyBoard->setText("Hide Keyboard");


  • welcome to devnet

    I have added code tags for increased readability. Please check out the "forum guidelines":http://qt-project.org/wiki/ForumHelp#e3f82045ad0f480d3fb9e0ac2d58fb01 and use code tags next time.

  • ok thanks, first timer

  • Hi Minz
    Can you debug the value of (this->height()-320) ? I wonder if you are inputing a negative value in setFixedHeight(), that would cause that warning ?

  • Just debugged it, the original height is 651, which becomes 331 after subtracting 320. The value of height alternates between 651 and 331. Also, it not only gives a warning but makes the background of my text widgets black.

  • Before I switched to a 5.0.2 compiler it was working fine, I initially had 4.8.4, but since the project i'm working on will be assessed on a machine with qt 5, i had to change it. Gratitude to whoever can help

  • Moderators

    maybe this may help you:
    this->setFixedSize( QLayout::closestAcceptableSize ( this, this->size()-QSize(0,320) ) );

  • will try it, thanks for ur concern

Log in to reply