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. Graphical artifacts in QPushButton
Forum Updated to NodeBB v4.3 + New Features

Graphical artifacts in QPushButton

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

    Hi,
    I have class of buttons that inherits QPushButton. I set style of this button by setting setStyleSeet method.
    I have QWidget container that is parent for my buttons and for other QWidget fullWidget. Buttons have its own position, but fullWidget is expanding to its parent. Buttons are raised over fullWidget. But when I do this (raise) the artifacts is showing. For example, buttons have rounded corners, but after raising they have grey background

    !http://oi61.tinypic.com/1p9ulz.jpg()! - image is painted by me, it's only to show what is wrong.

    Any idea how to fix it?

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vezprog
      wrote on last edited by
      #2

      I believe that is just the frame in the background of the button. Once you style the button, you have to basically redo everything that the default button style has unless you just change the palette properties.

      To fix the gray background, you can make the background of the button transparent (but not the frame with the rounded edges and text).

      So you can add to your stylesheet:

      @
      QPushButton {
      "background:transparent;"
      ...
      ...
      }
      @

      or you can set the background to translucent:

      @
      button->setAttribute(Qt::WA_TranslucentBackground);
      @

      1 Reply Last reply
      0
      • N Offline
        N Offline
        never_ever
        wrote on last edited by
        #3

        I have sth like this:

        @
        button->setStyleString("QPushButton{" +
        "padding: " + QString::number(width/3) + "px;" +
        "border-radius: " + QString::number(radius/5) + "px;" +
        "background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, " +
        "stop: 0 #3d94f6, stop: 1 #29569e);" +
        "background: transparent" +
        "color: white;" +
        "font-family: arial;" +
        "font-size: " + QString::number(fontSize) + "px;" +
        "font-weight: bold" +
        "}" +
        "QPushButton:hover{" +
        "border: 2px solid black;" +
        "border-radius: " + QString::number(radius/4) + "px;" +
        "background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, " +
        "stop: 0 #29569e, stop: 1 #3d94f6);" +
        "}"+
        "QPushButton:checked{" +
        "border: 3px solid black;" +
        "border-radius: " + QString::number(radius/3) + "px;" +
        "background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, " +
        "stop: 0 #29569e, stop: 1 #3d94f6);" +
        "}");

        @

        I tried that two methods:

        @

        QPushButton{
        "background:transparent;"
        ...
        ...
        }

        @

        and also

        @

        button->setAttribute(Qt::WA_TranslucentBackground);

        @

        but it didn't work (nothing changed)

        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