February 28, 2011

Ruzik Ruzik
Lab Rat
293 posts

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!

4 replies

March 1, 2011

Mazur Mazur
Ant Farmer
9 posts

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.

 Signature 

delete this->signature;

March 1, 2011

Ruzik Ruzik
Lab Rat
293 posts

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

March 1, 2011

Mazur Mazur
Ant Farmer
9 posts

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

  1. void Search::paintEvent(QPaintEvent *)
  2. {
  3.  QStylePainter barPainter(this);
  4.  QStyleOption barOption;
  5.  barOption.initFrom(this);
  6.  barPainter.drawPrimitive(QStyle::PE_Widget, barOption);
  7. }

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.

 Signature 

delete this->signature;

March 2, 2011

Ruzik Ruzik
Lab Rat
293 posts

Thank you very musc!

 
  ‹‹ QProcess && send mail from Linux      qtextdocument and qtexttable - align text ››

You must log in to post a reply. Not a member yet? Register here!