Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [solved] resize the screen
Forum Updated to NodeBB v4.3 + New Features

[solved] resize the screen

Scheduled Pinned Locked Moved General and Desktop
7 Posts 2 Posters 1.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    solo117117
    wrote on last edited by
    #1

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

    1 Reply Last reply
    0
    • A Offline
      A Offline
      ambershark
      wrote on last edited by
      #2

      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:

      @
      myTable->hide();
      @

      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.

      My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

      1 Reply Last reply
      0
      • S Offline
        S Offline
        solo117117
        wrote on last edited by
        #3

        Thank you so much!

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

        I want whenever I resize the width and height appears

        1 Reply Last reply
        0
        • A Offline
          A Offline
          ambershark
          wrote on last edited by
          #4

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

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

          // implementation
          void MyWidget::resizeEvent(QResizeEvent *event)
          {
          ui->lineEdit_widht->setText(event->size().width());
          ui->lineEdit_height->setText(event->size().height());
          }
          @

          My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

          1 Reply Last reply
          0
          • S Offline
            S Offline
            solo117117
            wrote on last edited by
            #5

            Thank you so much ambershark :)

            1 Reply Last reply
            0
            • A Offline
              A Offline
              ambershark
              wrote on last edited by
              #6

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

              My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

              1 Reply Last reply
              0
              • S Offline
                S Offline
                solo117117
                wrote on last edited by
                #7

                done :)

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved