Unable to fully remove border of PyQt QGraphicsView

2024/10/11 18:22:10

I have tried calling self.setStyleSheet("background: transparent; border: transparent;") on a QGraphicsView, but it still leaves a 1 pixel border on the top edge. I have also tried replacing border: transparent; with border-style: none;, but it didn't work either.

Here is a screenshot of the problem:

Problematic line

What command will fully remove the border from the QGraphicsView?

Answer

You can use one of the following css rule:

graphicsView.setStyleSheet("border-width: 0px; border-style: solid")

or

graphicsView.setStyleSheet("border: 0px")

Your border should disappear.

import sys
from PyQt4.QtGui import *class Ui(QWidget):def __init__(self, parent=None):QWidget.__init__(self, parent)graphicsView = QGraphicsView()graphicsView.setStyleSheet("border: 0px")grid = QGridLayout()grid.addWidget(graphicsView)self.setLayout(grid)app = QApplication(sys.argv)
ui = Ui()
ui.show()
sys.exit(app.exec_())

Here is the widget with the default style:

enter image description here

And now the widget with the style applied:

enter image description here

https://en.xdnf.cn/q/69739.html

Related Q&A

SqlAlchemy non persistent column

I am trying to define a model using sqlalchemy such that one of the columns i only need in memory for processing, i do not have a corresponding database column for that. I need it such that when i save…

Creating command line alias with python

I want to create command line aliases in one of my python scripts. Ive tried os.system(), subprocess.call() (with and without shell=True), and subprocess.Popen() but I had no luck with any of these me…

Remove unwanted lines in captcha text - opencv - python

I trying to get text from captcha image using opencv. Problem is text are masked with noise and it is complex to process with those horizontal line/noise.Original imageMy processed image :not sure how …

Double Summation in Python

I am trying to write a code to conduct a double summation (see pic) in which; M is the subjects, N is the Trials, Yijt is the measured wave form data (3d array)so far I have; Given Y is the data arra…

psycopg, double and single quotes insert

I ran into problems, while trying to insert to database:ur_psql.execute("""insert into smth(data, filedate, filedby)"""""" values(%s, NOW(), %s)""…

How to debug Python 2.7 code with VS Code?

For work I have to use Python 2.7. But when I use the "debug my python file" function in VS Code, I get an error. Even with a simple program, like : print()

Python Sequence of Numbers

Ive decided not to waste my summer and start learning python. I figured Id start learning looping techniques so I wanted to start with a basic list of numbers, aka, write a for loop that will generate…

Object initializer syntax (c#) in python?

I was wondering if there is a quick way to initialise an object in python. For example in c# you can instantiate an object and set the fields/properties like...SomeClass myObject = new SomeClass() { va…

Plotly.io doesnt see the psutil package even though its installed

Im trying to execute the following code:import numpy as np import pandas as pd import matplotlib.pyplot as plt import matplotlib %matplotlib inline import seaborn as snsimport plotly.graph_objects as g…

How to get MultiCells in Pyfpdf Side by side?

I am making a table of about 10 cells with headings in them. They will not fit accross the page unless I use multi_cell option. However I cant figure out How to get a multi_cell side by side. When I ma…