Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Qframe lines and QTextEdit scrollbar are not drawn correctly



  • Hello Community

    As you can see in the pictures, not all frame lines of a QTableView are drawn correctly and the scrollbar of a QTextEdit is also not drawn correctly.

    Screenshot1
    Screenshot2

    Class with the QTableWidget:

    class DateTable : public QWidget
    {
    	Q_OBJECT
    
    public:
    	explicit DateTable(QWidget* parent = nullptr) :
    		QWidget(parent)
    	{
    		tool_bar = new QToolBar(tr("tool_bar"), this);
    		tool_bar->addAction(tr("Add Row"));
    		tool_bar->addAction(tr("Delete Row"));
    
    		table_view = new QTableView(this);
    
    		QVBoxLayout* vbox_layout = new QVBoxLayout(this);
    
    		vbox_layout->addWidget(tool_bar);
    		vbox_layout->addWidget(table_view);
    
    		setLayout(vbox_layout);
    		layout()->update();
    	}
    
    private:
    	QToolBar* tool_bar;
    	QTableView* table_view;
    };
    

    Does anyone know what I can do to ensure that the lines are drawn correctly or what I am doing wrong so that the lines are not drawn correctly?



  • Do you have a stylesheet set for the application or the widgets that get drawn incorrectly?



  • @gde23
    Thanks for the answer.

    No, I don't have set a style sheet yet. I briefly looked at the following pages from the Qt documentation:
    Qt Style Sheets Reference
    Qt Style Sheets Examples
    QWidget styleSheet : QString
    QApplication styleSheet : QString

    I I'll try this later as I don't have a lot of time right now.

    Do I have to define a stylesheet so that the widgets are drawn correctly?



  • @titan99_ said in Qframe lines and QTextEdit scrollbar are not drawn correctly:

    Do I have to define a stylesheet so that the widgets are drawn correctly?

    No, he just means stylesheet may cause that kind of incorrect drawing.
    I tried your code and the frame is drawn without problem, so this part doesn't seem to be the reason.



  • @Bonnie said in Qframe lines and QTextEdit scrollbar are not drawn correctly:

    I tried your code and the frame is drawn without problem, so this part doesn't seem to be the reason.

    Thank you very much for your effort.

    I changed the screen scaling settings from 125% to 100% and the widgets were drawn correctly.

    In the documentation I found these pages about high DPI:
    enum class Qt::HighDpiScaleFactorRoundingPolicy
    High DPI, this side says:

    Qt will automatically account for the display resolution when using higher level APIs such as Qt Widgets and Qt Quick, and applications only need to provide high-resolution assets, such as images and icons.

    I searched for high dpi using the forum's search function.

    The return value from main_window.devicePixelRatio(); was 1.25, which corresponds to my system setting. But with the scaling 1.25 the problem remains.

    Edit:

    QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::Round);
    QApplication app(argc, argv);
    

    If the static member function setHighDpiScaleFactorRoundingPolicy before QApplication app (argc, argv); is called, everything was drawn as expected. highDpiScaleFactorRoundingPolicy() previously returned 5, which corresponds to Qt :: HighDpiScaleFactorRoundingPolicy::PassThrough.


Log in to reply