Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. QwtPlot Palette overwritten by Qmainwindow stylesheet.

QwtPlot Palette overwritten by Qmainwindow stylesheet.

Scheduled Pinned Locked Moved 3rd Party Software
3 Posts 2 Posters 5.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.
  • J Offline
    J Offline
    Jermcb
    wrote on last edited by
    #1

    Hi,

    I set the background color of a QwtPlot. Then I add it to a dock widget, then add the dockwidget to a QMainWindow.

    The background color works well until I add a style sheet to the mainwindow as follows:

    this->setStyleSheet("QMainWindow::separator {background: rgb(255, 255, 255);width: 2px; height: 2px;}");

    I set the background color of the QwtPlot as folows:
    @
    QPalette pal = palette();
    QColor LightBlue;
    LightBlue.setRgb(110,180,220,255);
    QLinearGradient gradient( 0, 0, 0, 1 );
    gradient.setCoordinateMode( QGradient::StretchToDeviceMode );
    gradient.setColorAt( 0.0, Qt::white );
    gradient.setColorAt( 0.7, LightBlue );
    gradient.setColorAt( 1.0, LightBlue );
    pal.setBrush( QPalette::Window, gradient );

    Plot->setPalette( pal );
    

    @

    Does anyone know how to overcome this?

    I have tried setting the mainwindow stylesheet before and after the QwtPlot palette setting. No change.

    Thank you!

    1 Reply Last reply
    0
    • M Offline
      M Offline
      messi
      wrote on last edited by
      #2

      Hi

      when I changed the background color of the QwtPlot I used Stylesheet.
      @
      QString stytleSheetString1 = " QwtPlot { border: 2px solid %1; border-radius: 10px; background-color: %1; font-size: 11px; }";@
      Try to avoid mixing QPalette and StyleSheet.
      The ordering when which is used is not guaranteed .

      As a test, comment the setStylesheet line and add setBrush(Qt::red);
      Why don't you use QPalette within the QMainwindow?

      1 Reply Last reply
      0
      • J Offline
        J Offline
        Jermcb
        wrote on last edited by
        #3

        Thank you messi.

        I have figured out how to do it now. It was a problem with stylesheet and QPalette.

        Just a note, if you want to set the background color of the plot use:

        @Plot->canvas()->setStyleSheet(" QwtPlotCanvas { background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #f6f7fa, stop: 1 #dadbde); }");@

        Then to change the border around the plot (including the axes and such) use:
        @Plot->setStyleSheet(" QwtPlot { background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #f6f7fa, stop: 1 #dadbde); }");@

        Thanks again.

        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