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. [solved] If it is possible to set position:relative in setStyleSheet to QPushButton?

[solved] If it is possible to set position:relative in setStyleSheet to QPushButton?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 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.
  • N Offline
    N Offline
    never_ever
    wrote on last edited by
    #1

    Hi,
    I was wondering if there is possibility to set position:relative to QPushbutton using stylesheet, because I have tried this and nothing happens.

    @
    QString style = QString("QPushButton{") +
    "background-color: #3d94f6;" +
    "border: 1px solide #29569e;" +
    "border-radius: 5px;" +
    "background: qlineargradient(x1: 0, y1:0, x2: 0, y2: 1, " +
    "stop: 0 #3d94f6, stop: 1 #29569e);" +
    "font-family: arial;" +
    "font size: 12px;" +
    "}"+
    "QPushButton:hover{" +
    "background-color: #3d94f6;" +
    "border: 1px solide #29569e;" +
    "border-radius: 5px;" +
    "background: qlineargradient(x1: 0, y1:0, x2: 0, y2: 1, " +
    "stop: 0 #29569e, stop: 1 #3d94f6);" +
    "font-family: arial;" +
    "font size: 12px;" +
    "}"+
    "QPushButton:checked{" +
    "position:relative;" +
    "top: 3px;"+
    "background: qlineargradient(x1: 0, y1:0, x2: 0, y2: 1, " +
    "stop: 0 #29569e, stop: 1 #3d94f6);" +
    "}"
    @

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

      Hi,

      AFAIK and unless I'm mistaken, the position keyword can only be used for sub controls

      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
      0
      • N Offline
        N Offline
        never_ever
        wrote on last edited by
        #3

        It's a pity. So maybe I can change font size?

        EDIT: Ok, I get the same clicking effect by setting shadow to button and resizing font.

        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