Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Unsolved Font Size Problem

    Mobile and Embedded
    3
    4
    1009
    Loading More Posts
    • 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.
    • Z
      ZekDe last edited by

      Hi friends,
      I'm running my codes and first groupBox's font size equals label above ,you will understand what I mean .These are my codes. groupBox_1 giving my intention result but groupBox giving labelBluetoothAdress fontsize.I cannot solve it.

      /// \brief labelTitle
      //
      mfont.setPointSize(round(10*ui->labelTitle->geometry().height()/gbox));
      ui->labelTitle->setFont(mfont);
      ui->labelTitle->setStyleSheet(QStringLiteral("color: #0095d6"));
      ui->labelTitle->setAlignment(Qt::AlignHCenter);

                  /// \brief labelBluetoothAdress
                  ///
                  mfont.setPointSize(round(10*ui->labelBluetoothAdress->geometry().height()/10));
                  ui->labelBluetoothAdress->setFont(mfont);
                  ui->labelBluetoothAdress->setAlignment(Qt::AlignHCenter);
                  /*********///6 adet Group Box nesnelerini uygun şekilde yerleştirmek için başlık ve bluetooth adresinin yazılacağı nesnelerin yükseklikleri dahil edilmiyor.
                  //int hh = round(h - 1.6*(ui->labelTitle->geometry().height() + ui->labelBluetoothAdress->geometry().height()));
                  /*********/
                  //////////Tüm groupBox Ayarları////////////
                  ///
                  /// \brief groupBox
                  ///
                  QRect gb;
      
                  gb = ui->groupBox->geometry();
                  mfont.setPointSize(round(gb.height()/gbox));
                  mfont.setBold(false);
                  ui->groupBox->setFont(mfont);
      
                  mfont.setPointSize(round(ui->customPlot->geometry().height()/cPlot));
                  mfont.setBold(false);
                  ui->customPlot->xAxis->setTickLabelFont(mfont);
                  ui->customPlot->yAxis->setTickLabelFont(mfont);
      
                  mfont.setPointSize(round(ui->labelDisplay->geometry().height())/cnst);
                  mfont.setBold(true);
                  ui->labelDisplay->setFont(mfont);
                  ui->labelDisplay->setAlignment(Qt::AlignRight);
      
                  mfont.setPointSize(round(ui->labelUnity->geometry().height()/cnst));
                  mfont.setBold(true);
                  ui->labelUnity->setFont(mfont);
                  ui->labelUnity->setAlignment(Qt::AlignLeft);
      
      
                  /// \brief groupBox_1
                  ///
                  gb = ui->groupBox_1->geometry();
      
                  mfont.setPointSize(round(gb.height()/gbox));
                  mfont.setBold(false);
                  ui->groupBox_1->setFont(mfont);
      
                  mfont.setPointSize(round(ui->customPlot_1->geometry().height()/cPlot));
                  mfont.setBold(false);
                  ui->customPlot_1->xAxis->setTickLabelFont(mfont);
                  ui->customPlot_1->yAxis->setTickLabelFont(mfont);
      
                  mfont.setPointSize(round(ui->labelDisplay_2->geometry().height())/cnst);
                  mfont.setBold(true);
                  ui->labelDisplay_2->setFont(mfont);
                  ui->labelDisplay_2->setAlignment(Qt::AlignRight);
      
                  mfont.setPointSize(round(ui->labelUnity_2->geometry().height()/cnst));
                  mfont.setBold(true);
                  ui->labelUnity_2->setFont(mfont);
                  ui->labelUnity_2->setAlignment(Qt::AlignLeft);
      
      jsulm 1 Reply Last reply Reply Quote 0
      • jsulm
        jsulm Lifetime Qt Champion @ZekDe last edited by

        @ZekDe said in Font Size Problem:

        mfont.setPointSize(round(10*ui->labelBluetoothAdress->geometry().height()/10));

        You multiply by 10 and then devide by 10 - what's the point?

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply Reply Quote 1
        • Z
          ZekDe last edited by

          I got this problem,I am getting 'size < 0' this is why I think program assign default value maybe previous value .

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            Hi,

            In addition to the point made by @jsulm, when are you calling that code ? If it's in the constructor then you are using invalid values. No geometry is known at construction time, it's only when a widget is shown that its geometry becomes real.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply Reply Quote 1
            • First post
              Last post