Search code examples
c++qtuser-interfaceqt3

How to ignore resize event in Qt3?


when i increase left dock area size (manually) main window increases its size also. but it has no limit!. it can get wider than screen size. i want to prevent it. i tried re-implementing main window's resizeEvent() method. this is what i have tried.

void MyMain::resizeEvent(QResizeEvent *e)
{
     if (newMainWindowWidth > screenWidth)
     {
          leftDockWindow->setFixedExtentWidth(
                   leftDockWidth - (newWidth - screenWidth));
          leftDockWindow->adjustSize();
          adjustSize(); // flicker effect :(
     }
}

this works. but it has a flicker effect because i'm adjusting size again. i think that i can solve this by ignoring the event. but i can't find a way to do that. please help !! thanks.


Solution

  • The solution is ...

    bool MyClass::eventFilter(QObject *obj, QEvent *e)
    {
        if (e->type() == QEvent::Resize)
        {
            if (obj == myObj)
            {
                doSomethingWithObj(); 
                return true;
            }
            else
            {
                return false;
            }
        }
        else
        {
            return QWidget::eventFilter(obj, e);;
        }
    }