Important: Please read the Qt Code of Conduct -

[solved] resize the screen

  • I want to delete a table if the width is smaller than 500
    if the user resizes the screen then
    in Qt

  • Moderators

    What do you mean by delete a table? Do you mean like hide the widget or remove it from the layout entirely?

    To hide it you can just use:


    To find when your window is resizing just override QWidget::resizeEvent(). That will let you find new sizes so when it goes below the "500" you are concerned with you can then hide the table or whatever you need to do.

  • Thank you so much!

    @int width = this->width();
    int height = this->height();
    QString s_widht = QString::number(width);
    QString s_height = QString::number(height);

    I want whenever I resize the width and height appears

  • Moderators

    Well that code would work, just add it to your MyWidget::resizeEvent(...) function, like so:

    // header
    class MyWidget : public QWidget
    // ...
    void resizeEvent(QResizeEvent *event);

    // implementation
    void MyWidget::resizeEvent(QResizeEvent *event)

  • Thank you so much ambershark :)

  • Moderators

    Looks good, glad it worked. :) Make sure to add [solved] to the thread title.

  • done :)

Log in to reply