i writing application custom window shell. shell has rounded corners , transparency. here sample code of how doing this:
mywindow::mywindow (void) : qmainwindow (null, qt::framelesswindowhint) { setattribute (qt::wa_translucentbackground); setattribute (qt::wa_nosystembackground ); }
the problem whenever use wa_translucentbackground framelesswindowhint, font rendering becomes awful, see image below. have custom application style set through global css. tried using other fonts such segoe ui font becomes changed.
any ideas on why happening , can fix problem. using c++ qt 5.0.2
it looks may have found solution. first of all, can use qwidget::setmask in order rounded corners if prefer not use qt::wa_translucentbackground. here sample code came with:
void mywindow::setvisible (bool visible) { // call default event qmainwindow::setvisible (visible); // set rounded mask (size() needs correct) qbitmap t (size()); t.fill (qt::color0); qpainter p (&t); p.setbrush (qt::color1); p.drawroundedrect (rect(), 5, 5); setmask (t); }
for transparency have make font prefer antialiasing. can put @ start of application.
qfont font = qapplication::font(); font.setstylestrategy (qfont::preferantialias); qapplication::setfont (font);
not perfect fixed problem having.
Comments
Post a Comment