Posts

Qt Snippet: Render SVG to QPixmap for high DPI screen

Image
Convert a SVG image to QPixmap format is a very easy operation using the Qt classes. Common examples that is possible to find into documentation, however, refer to a situation where the screen device have standard pixel ratio of 1.

Qt Designer: develop custom widget plugin getting mouse events

Image
If you want to develop a custom Qt widget to distrbute or sell a good habits is always to develop, in addition, a plugin working into Qt Designer allowing to visually use and configure your custom widget inside the designer GUI editor. Develop such plugin is not a difficult task, official documentation and examples are here and, as usual for Qt, all is well explained.

Online graphic text or logo creators

Image
Another important task of software development is to create a good graphic elements for make the interface look better. Graphic texts, icons, logos and so on are all parts of a good product. If you, like me, are not so good in graphic design we need some help...

Qt Snippet: QGraphicsView fitInView() and the unwanted margins bug

Image
In case you are working with Qt Graphics View Framework you probably make use of the QGraphicsView method fitInView() . This function, based to the official documentation, scales the view matrix and scrolls the scroll bars to ensure that the scene rectangle rect fits inside the viewport. 

Qt Snippet: Rounded corners QPushButton inside QGraphicsScene

Image
QGraphicsScene is a great Qt component allowing to develop full graphics applications (like game for example) in a very easy way. As additional feature is possible to insert a QWidget based object inside the scene through the QGraphicsProxyWidget item.

Qt Snippet: QPushButton with word wrap feature

Image
Qt have two main classes to use as button widget, QPushButton and QToolButton. These classes made the job in a very good way but both miss the word wrap feature. If the button width is not enough for show the entire button text the string is cutted out on sides and this is not a good effect. Word wrap feature allow the control to automatically move part of the text in a new line for allow full view.

Qt Snippet: QLabel with text shadow

Image
In case you want to show your text labels a little more "beautiful" to see a little trick is to add shadow to text and create a 3D text like. In the CSS standard set exist a tag called text-shadow able to apply such effect automatically. Unfortunately this feature is not supported by the Qt QSS stylesheet set so we need to found another way.