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. QString % symbol
Qt 6.11 is out! See what's new in the release blog

QString % symbol

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 1.2k 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.
  • SPlattenS Offline
    SPlattenS Offline
    SPlatten
    wrote on last edited by SPlatten
    #1

    How do you add a % symbol to a string built with QString?

    For example I have:

    QString strStyle(QString("QSlider::groove{background:transparent;}"
                             "QSlider::handle:vertical{"
                             "background:black;"
                             "border-radius:0px"
                             "border:1px solid gray;"
                             "height:%1%}").arg(dblPercentOnView));
    

    The % doesn't work.

    Kind Regards,
    Sy

    SPlattenS 1 Reply Last reply
    0
    • SPlattenS SPlatten

      How do you add a % symbol to a string built with QString?

      For example I have:

      QString strStyle(QString("QSlider::groove{background:transparent;}"
                               "QSlider::handle:vertical{"
                               "background:black;"
                               "border-radius:0px"
                               "border:1px solid gray;"
                               "height:%1%}").arg(dblPercentOnView));
      

      The % doesn't work.

      SPlattenS Offline
      SPlattenS Offline
      SPlatten
      wrote on last edited by SPlatten
      #2

      @SPlatten , actually its quite simple:

      QString strStyle(QString("QSlider::groove{background:transparent;}"
                               "QSlider::handle:vertical{"
                               "background:black;"
                               "border-radius:0px"
                               "border:1px solid gray;"
                               "height:%1%2;}").arg(dblPercentOnView).arg("%"));
      

      Kind Regards,
      Sy

      KroMignonK JonBJ 2 Replies Last reply
      0
      • SPlattenS SPlatten

        @SPlatten , actually its quite simple:

        QString strStyle(QString("QSlider::groove{background:transparent;}"
                                 "QSlider::handle:vertical{"
                                 "background:black;"
                                 "border-radius:0px"
                                 "border:1px solid gray;"
                                 "height:%1%2;}").arg(dblPercentOnView).arg("%"));
        
        KroMignonK Offline
        KroMignonK Offline
        KroMignon
        wrote on last edited by
        #3

        @SPlatten said in QString % symbol:

        actually its quite simple:

        Or even easier with:

        QString strStyle(QString("QSlider::groove{background:transparent;}"
                                 "QSlider::handle:vertical{"
                                 "background:black;"
                                 "border-radius:0px"
                                 "border:1px solid gray;"
                                 "height:%1%;}").arg(dblPercentOnView));
        

        It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

        SPlattenS 1 Reply Last reply
        1
        • KroMignonK KroMignon

          @SPlatten said in QString % symbol:

          actually its quite simple:

          Or even easier with:

          QString strStyle(QString("QSlider::groove{background:transparent;}"
                                   "QSlider::handle:vertical{"
                                   "background:black;"
                                   "border-radius:0px"
                                   "border:1px solid gray;"
                                   "height:%1%;}").arg(dblPercentOnView));
          
          SPlattenS Offline
          SPlattenS Offline
          SPlatten
          wrote on last edited by
          #4

          @KroMignon , doesn't % denote a parameter expected?

          Kind Regards,
          Sy

          1 Reply Last reply
          0
          • SPlattenS SPlatten

            @SPlatten , actually its quite simple:

            QString strStyle(QString("QSlider::groove{background:transparent;}"
                                     "QSlider::handle:vertical{"
                                     "background:black;"
                                     "border-radius:0px"
                                     "border:1px solid gray;"
                                     "height:%1%2;}").arg(dblPercentOnView).arg("%"));
            
            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by JonB
            #5

            @SPlatten said in QString % symbol:

            "height:%1%2;}").arg(dblPercentOnView).arg("%"));

            For a literal % you should find QString accepts %%, so I would find simpler/more readable

            "height:%1%%;}").arg(dblPercentOnView));`
            
            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