Qss and QDockWidget



  • Hello, i found a bug in the QDockWidget in the qss
    Does not want to set background image in the QDockWidget
    I try to write
    thus: url(:/All/SearchBackground.png);
    thus: border-image: url(:/All/SearchBackground.png);
    and thus: background-image: url(:/All/SearchBackground.png);
    And placed either no image or a need picture but whith some scraps
    Thanks in advance, and sorry for bad english!



  • Hi Ruzik, have you got Q_OBJECT in your QMainWindow or child of QDockWidget? If yes then you need to rewrite paintEvent. Try documentation, there was an example how to do it.



  • Class is the child of QDockWidget, please help me with rewrite:
    I write in class:
    protected:
    void paintEvent ( QPaintEvent * event );
    And in cpp file
    void Search::paintEvent ( QPaintEvent * event )
    {
    this->repaint();
    }
    And an error of unhandled exception
    Error on this line-> this->repaint();
    I find information in assist, but i dont foind anythink
    P.S. Thank you very much for your attention



  • Hi Ruzik, I am sorry for long response and here is the code for paintEvent:

    @void Search::paintEvent(QPaintEvent *)
    {
    QStylePainter barPainter(this);
    QStyleOption barOption;
    barOption.initFrom(this);
    barPainter.drawPrimitive(QStyle::PE_Widget, barOption);
    }@

    It should be done with all Widgets that have Q_OBJECT and you want to use stylesheet with them, it was somewhere in the documentation but this stylesheet section is really messy and I can't find it anymore. Hopefully it works.



  • Thank you very musc!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.