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. Fit & Resizable QLCDNumber
Forum Updated to NodeBB v4.3 + New Features

Fit & Resizable QLCDNumber

Scheduled Pinned Locked Moved Unsolved General and Desktop
16 Posts 2 Posters 2.7k 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.
  • CodeFreaksC Offline
    CodeFreaksC Offline
    CodeFreaks
    wrote on last edited by CodeFreaks
    #7

    Thanks,
    but why "contentsRect()" doesn't return the accurate width and height of widgets, too?

    mrjjM 1 Reply Last reply
    0
    • CodeFreaksC CodeFreaks

      Thanks,
      but why "contentsRect()" doesn't return the accurate width and height of widgets, too?

      mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #8

      Hi
      it should be make sure the widget is visible before you read it.

      1 Reply Last reply
      1
      • CodeFreaksC Offline
        CodeFreaksC Offline
        CodeFreaks
        wrote on last edited by CodeFreaks
        #9

        Hi,
        Thanks for reply.

            if(currentLCDNum1->isVisible()){
            cout<<"Main   LCD  W: "<<myLCDRect.width()<<"   H: "<<myLCDRect.height()<<endl;
            }
        
        Main   LCD  W: 96   H: 26
        

        Am I doing wrong?

        mrjjM 1 Reply Last reply
        0
        • CodeFreaksC CodeFreaks

          Hi,
          Thanks for reply.

              if(currentLCDNum1->isVisible()){
              cout<<"Main   LCD  W: "<<myLCDRect.width()<<"   H: "<<myLCDRect.height()<<endl;
              }
          
          Main   LCD  W: 96   H: 26
          

          Am I doing wrong?

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #10

          @CodeFreaks
          Nope, looks good.
          The reported sizes 96,26 is not correct ?

          CodeFreaksC 1 Reply Last reply
          0
          • mrjjM mrjj

            @CodeFreaks
            Nope, looks good.
            The reported sizes 96,26 is not correct ?

            CodeFreaksC Offline
            CodeFreaksC Offline
            CodeFreaks
            wrote on last edited by CodeFreaks
            #11

            @mrjj
            Thanks,
            No, it's not correct. I think the width of parent widget (Frame1) is 96 . Both QLCDNumbers reported the same height but as you can see in first post they are different, in size.

            mrjjM 1 Reply Last reply
            0
            • CodeFreaksC CodeFreaks

              @mrjj
              Thanks,
              No, it's not correct. I think the width of parent widget (Frame1) is 96 . Both QLCDNumbers reported the same height but as you can see in first post they are different, in size.

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #12

              @CodeFreaks
              Hi I was wondering what myLCDRect is ? ( i read is a LCdNumber, but seems wrong, reading it again)
              If its a QRect, you take before LCD is shown, it might no be correct.

              i made this test form
              alt text
              and did

              void MainWindow::on_pushButton_released() {
                   qDebug() <<"Main   LCD  W: "<<ui->lcdNumber_1->width()<<"   H: "<<ui->lcdNumber_1->height();
                   qDebug() <<"second LCD  W: "<<ui->lcdNumber_2->width()<<"   H: "<<ui->lcdNumber_2->height();
              }
              result is.
              Main   LCD  W:  91    H:  31
              second LCD  W:  131    H:  71
              

              Which seems pretty ok ?

              CodeFreaksC 1 Reply Last reply
              1
              • mrjjM mrjj

                @CodeFreaks
                Hi I was wondering what myLCDRect is ? ( i read is a LCdNumber, but seems wrong, reading it again)
                If its a QRect, you take before LCD is shown, it might no be correct.

                i made this test form
                alt text
                and did

                void MainWindow::on_pushButton_released() {
                     qDebug() <<"Main   LCD  W: "<<ui->lcdNumber_1->width()<<"   H: "<<ui->lcdNumber_1->height();
                     qDebug() <<"second LCD  W: "<<ui->lcdNumber_2->width()<<"   H: "<<ui->lcdNumber_2->height();
                }
                result is.
                Main   LCD  W:  91    H:  31
                second LCD  W:  131    H:  71
                

                Which seems pretty ok ?

                CodeFreaksC Offline
                CodeFreaksC Offline
                CodeFreaks
                wrote on last edited by CodeFreaks
                #13

                @mrjj
                Hi, thanks for reply.
                Is there any way that we can achieve true sizes before they are shown?
                If there isn't, How can we do that without user signals (pushbutton) ?

                mrjjM 1 Reply Last reply
                0
                • CodeFreaksC CodeFreaks

                  @mrjj
                  Hi, thanks for reply.
                  Is there any way that we can achieve true sizes before they are shown?
                  If there isn't, How can we do that without user signals (pushbutton) ?

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #14

                  @CodeFreaks
                  Hi
                  often they have sizeHint size but why you need this before shown ?

                  I though goal was to let LED1.height be 0.75 of Led2.Height

                  or did i completely misunderstand the goal?

                  CodeFreaksC 1 Reply Last reply
                  1
                  • mrjjM mrjj

                    @CodeFreaks
                    Hi
                    often they have sizeHint size but why you need this before shown ?

                    I though goal was to let LED1.height be 0.75 of Led2.Height

                    or did i completely misunderstand the goal?

                    CodeFreaksC Offline
                    CodeFreaksC Offline
                    CodeFreaks
                    wrote on last edited by CodeFreaks
                    #15

                    @mrjj
                    You are right,
                    If I can calculate the sizes before they are shown, without any events they will present with desire sizes at the beginning.
                    If a method exist which without any user signal, immediately after it is shown, reports the accurate sizes. It can be a good alternative, too.

                    mrjjM 1 Reply Last reply
                    0
                    • CodeFreaksC CodeFreaks

                      @mrjj
                      You are right,
                      If I can calculate the sizes before they are shown, without any events they will present with desire sizes at the beginning.
                      If a method exist which without any user signal, immediately after it is shown, reports the accurate sizes. It can be a good alternative, too.

                      mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on last edited by
                      #16

                      @CodeFreaks
                      Hi
                      You could make a custom widget based on QFrame and override
                      ResizeEvent and then set sizes for its LCD members.
                      http://doc.qt.io/qt-5/qwidget.html#resizeEvent

                      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