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. QSS : Make a QDoubleSpinBox looks like a QLabel when disabled
Forum Updated to NodeBB v4.3 + New Features

QSS : Make a QDoubleSpinBox looks like a QLabel when disabled

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 263 Views
  • 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.
  • S Offline
    S Offline
    SylvainM
    wrote on last edited by
    #1

    Hi,
    I am trying to make a QDoubleSpinBox looks like a QLabel when disabled. So far, I am pretty satisfied with it. However, I wasn't able to align the text on the right.
    From the documentation I know that text-align is not the solution since it is not supported for QDoubleSpinBox or QLineEdit (even if I tried).
    I have tried a lot of things :

    QDoubleSpinBox {
      qproperty-alignment: 'AlignVCenter | AligRight';
    }
    
    QDoubleSpinBox QLineEdit {
      qproperty-alignment: 'AlignVCenter | AligRight';
    }
    
    QDoubleSpinBox * {
      qproperty-alignment: 'AlignVCenter | AligRight';
    }
    

    And yet the content of the spin box stays align on the left side of the underlying line edit. I even tried to do the following :
    QLineEdit {
    qproperty-alignment: 'AlignVCenter | AligRight';
    }

    Could anyone help me with this?

    1 Reply Last reply
    0
    • SeDiS Offline
      SeDiS Offline
      SeDi
      wrote on last edited by SeDi
      #2

      Instead of faking it, you could actually work with a changing component by using a Loader like this:

      Loader {
              anchors.fill: parent
              sourceComponent:  {
                      switch(whatever) {
                              case 0: return firstComponent;
                              case 1: return secondComponent;
                              case 2: return thirdComponent;
                              default: return defaultComponent;
                      }
              }
      }
      Component {
              id: firstCompoment
              QDoubleSpinBox {
                      // (...)
              }
      Component {
              id: secondComponent
              QLabel {
                      // (...)
              }
      
      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