Removing arrows from scrollbar in Qt - qt

I'm using a small black and white screen and need the scrollbar to just be a black slider in a black outer frame. I got what I wanted using style sheets but including them in the configuration when installing takes up too much space so I can't use them. Is it possible to remove the arrows by inheriting from QStyle or something?
thanks

You should create a subclass of a QStyle (or some subclass like QCommonStyle) and reimplement its drawComplexControl() function to paint CC_ScrollBar element by yourself.
Read QStyle's documentation for more.

This might be a dumb answer but would it help if you just specified the style sheet itself in code as a QString argument to setStyleSheet rather than maintain a separate file for it?

You can try to change palette settings for your scroll bar (according to designer scroll bar arrow color is "button text" color), but this approach looks lick little hack...
More "heavy" approach, is inherit from scroll bar widget and reimplement paint method, but there are it is looks like overkill...
So, you must choose little hack vs overkill :). Though maybe there are exist another solution

Related

Custom shaped menu with shadow in Qt

I'd like to create a context menu looking similar to this one:
I read suggestions on the web that QWidget::setMask() should be used to create a shape. But how can it fit the variable number of items then? Moreover, the same menu item may take more or less screen space on different machines.
Another question is how to create a shadow around this custom shape? As far as I understand, the mask allows to crop the widget, but not to make it semi-transparent.
I don’t found an easy way to do that! But here goes a way!
Instead of using the Qt mask API, I've used a frame-less widget with transparency enabled!
To draw the shadow, I've used radial gradient!
You can change the size of the menu before opening it, however you can’t resize it after opened (for example resize with mouse).
It’s quite easy add or remove widgets, just respect the layout margin to not draw outside the bounds destined to widgets. To simplify your life I created an inherited class of QPushButton with colors you can easily customize with style sheet.
See the result:
You can browse the source
Hope that helps!

How to customize the QTextEdit boundaries?

I'm very new to the designer mode of Qt.
I want QTextEdit to have a look exactly as shown in this . "High Score" should be part of the boundary. How is it possible to customize the qtextedit like this? Is it through QStylesheet I have to do that or it is possible to be done through the designer option of QtCreator? If it is through QStyleSheet, what is the command code for that?
Thanks
It is not possible to just configure QTextEdit to behave as you need it.
It may be much easier to draw the Border with the HIGH SCORES string in a widgets paintEvent() and place a QTextEdit with transparent background and borders into it. Set the margins of the layout big enough for the border to be visible around the QTextEdit.

How to make bootstraps's "split button" in Qt widgets

This is probably simple, though I can't find the correct CSS trick to handle this one.
I want to have this kind of button-group (separated with lines, containing a context menu ) in Qt. They must have native look and feel (not like below examples) so the only needed change seems to be removing rounded corners of a QPushButton from its right side (for left-most button), left side (for right most button) and both (for buttons in the middle).
Qt does not support this. You can use CSS to style the buttons like in the example, but you can not use natively styled buttons like this.
If you really need this, the only option I see is to write custom controls for this, with customized drawing code for each OS GUI style you want to support.
You could also try to use standard buttons that overlap and use custom code to paint some kind of line over the overlapping region, but I don't think that would be a good solution.

QTableView Zoom In/Out

I'm trying to create a QTableView that can be zoomed in and out like in Excel.
A similar question was asked here: Zooming function on a QWidget
However, I'm subclassing the QTableView in PyQt and not C so reimplementing the entire PaintEvent method is a bit evolved. The source code for that is a bit complex: https://qt.gitorious.org/qt/tiittane-qt/source/bdd4a9149789f60974603e1f7621d51378f0a108:src/gui/itemviews/qtableview.cpp#L1282
I'm looking to see if there are any other viable options to have a zoom able TableView. My first attempt was by setting the font size then realized each column and row widths would have to scale as well which can become slow. Then realized changing the font would change the print. It didn't seems like an elegant solution. Changing the scale of the painter before painting seems like the more elegant solution but would have to re-implement and translate quite a bit of code to python to do so. I'm wondering if there are any other hooks to get this done.
Thanks
If you can use QTableWidget instead then you can create a QGraphicsScene and add it to that. Then you easily control the scale of the widget within.
If you want vertical and horizontal headers always visible I think you will have to turn off the table's scrollbars (which would end up zoomed, probably not what you want anyways) and have the scrollbars part of the panel that contains the graphics scene (probably panel would be a QAbstractScrollArea with 4 cells in layout: one cell for scene, one for horiz scrollbar, one for vert scrollbar, and one for the corner maybe empty), and connect them to the table's scroll behavior.
There is no built-in method to zoom on a view.
The simplest way to separate the size of the font on the screen, versus the size of the font saved or printed, is to basically have two fonts. One to be displayed on the screen you can call 'zoom', versus the other to be saved/printed and call that 'font size'.
Note this answer is cut and pasted from the same question:
Zooming a view in PyQt?

QTableWidget colors, styles

I'm quite new to Qt and I'd appreciate the ability to customize a QTableWidget. I found a nice CSS-like interface using the stylesheets as shown here
http://doc.trolltech.com/4.3/stylesheet-examples.html#customizing-qtablewidget
However, I need to change some more specific styles (like grid color, items background color and so on).
I couldn't find any documentation describing the properties that might be changed via stylesheets.
Thanks for any help.
EDIT
Thanks, it helped a bit...however i still missed some other properties as grid thickness, but i "solved" it by inserting a row/column with 1px height/width to double the gridline :) And the QTableWidgetItem::setBackgroundColor() was also helpful.
However, I'm still facing some issues with QTableWidgetItem, the text keeps hiding if the column is too slim...only 3 dots appear. Dont you have an idea? I need the text to be visible, even if a bit clipped, but from the problem definition I cannot resize the column.
Isn't
http://doc.trolltech.com/4.3/stylesheet-reference.html#list-of-properties
the list you are looking for?

Resources