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. Customize QDoubleSpinBox text align with CSS
Forum Updated to NodeBB v4.3 + New Features

Customize QDoubleSpinBox text align with CSS

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 1.1k 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.
  • B Offline
    B Offline
    Bert59
    wrote on last edited by
    #1

    Hello,

    I try to customize a double spin box.

    In Qt designer I have the following lines in the style sheet editor.

    QDoubleSpinBox {font-size: 20px; text-align: right}

    QPushButton{text-align: right}

    0970bd91-7a0c-4a8e-b29a-48a878de3e37-image.png

    text-align: right has no effect in the spin box

    How can I change the alignment in the spin box?

    JonBJ 1 Reply Last reply
    0
    • B Bert59

      Hello,

      I try to customize a double spin box.

      In Qt designer I have the following lines in the style sheet editor.

      QDoubleSpinBox {font-size: 20px; text-align: right}

      QPushButton{text-align: right}

      0970bd91-7a0c-4a8e-b29a-48a878de3e37-image.png

      text-align: right has no effect in the spin box

      How can I change the alignment in the spin box?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @Bert59
      A QSpinBox has an internal QLineEdit child for the number text. I won't lie to you, I have had trouble accessing that fully, and reported a bug, but it never got addressed. But I did successfully change the text alignment (mine was from code, not stylesheet, for this). That is what you will need to set the text-align on. Try it from stylesheet rule (QDoubleSpinBox.QLineEdit or whatever the docs say the syntax is a for a child, I can't remember?), though that may be what I found did not work right. Or to verify my claim set the stylesheet directly from code on spinBox->lineEdit() to check it works. Note that method is protected, to access you either need to sub-class or use spinBox->findChild<QLineEdit *>().

      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