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. Print with fraction format in qLabel
Forum Updated to NodeBB v4.3 + New Features

Print with fraction format in qLabel

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 4 Posters 751 Views 3 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.
  • I Offline
    I Offline
    Isidro Perla
    wrote on last edited by
    #1

    Hello!, I want to print a fraction with a qlabel , for example
    44
    __
    22

    Here is my code
    ui->lb_fraction->setText(QString::number(44) + "/" + "QString::number(2) ");

    How Can I do for print as a fraction format that operation??????

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Do you mean something like:

      "44\n--\n22"
      

      ?

      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
      1
      • I Offline
        I Offline
        Isidro Perla
        wrote on last edited by
        #3

        Exactly, but I need to print something like thatejm1.png

        What I mean is one number multiplied by a fraction. I would prefer to show a html label or CSS styles, but I dont know how to do it.

        mrjjM JKSHJ 2 Replies Last reply
        0
        • I Isidro Perla

          Exactly, but I need to print something like thatejm1.png

          What I mean is one number multiplied by a fraction. I would prefer to show a html label or CSS styles, but I dont know how to do it.

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

          @Isidro-Perla
          Hi
          Could you not just use 3 labels and the line widget?

          alt text

          You can make it a reusable widget so you can easily have more if needed.

          1 Reply Last reply
          0
          • I Isidro Perla

            Exactly, but I need to print something like thatejm1.png

            What I mean is one number multiplied by a fraction. I would prefer to show a html label or CSS styles, but I dont know how to do it.

            JKSHJ Offline
            JKSHJ Offline
            JKSH
            Moderators
            wrote on last edited by
            #5

            @Isidro-Perla said in Print with fraction format in qLabel:

            I would prefer to show a html label or CSS styles

            You could try some of these: https://stackoverflow.com/questions/7525977/how-to-write-fraction-value-using-html

            ...but HTML and CSS don't have very good support for displaying fractions like that.

            Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

            mrjjM 1 Reply Last reply
            4
            • JKSHJ JKSH

              @Isidro-Perla said in Print with fraction format in qLabel:

              I would prefer to show a html label or CSS styles

              You could try some of these: https://stackoverflow.com/questions/7525977/how-to-write-fraction-value-using-html

              ...but HTML and CSS don't have very good support for displaying fractions like that.

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

              @JKSH
              I think the <sub> version is pretty decent in looks.
              alt text

              1 Reply Last reply
              2
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                You should take a look at Qwt's MathML renderer.

                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
                3

                • Login

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