Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qframe lines and QTextEdit scrollbar are not drawn correctly
QtWS25 Last Chance

Qframe lines and QTextEdit scrollbar are not drawn correctly

Scheduled Pinned Locked Moved Solved General and Desktop
high dpi
5 Posts 3 Posters 677 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    titan99_
    wrote on last edited by titan99_
    #1

    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?

    1 Reply Last reply
    0
    • gde23G Offline
      gde23G Offline
      gde23
      wrote on last edited by
      #2

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

      T 1 Reply Last reply
      0
      • gde23G gde23

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

        T Offline
        T Offline
        titan99_
        wrote on last edited by
        #3

        @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?

        B 1 Reply Last reply
        0
        • T titan99_

          @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?

          B Offline
          B Offline
          Bonnie
          wrote on last edited by
          #4

          @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.

          T 1 Reply Last reply
          1
          • B Bonnie

            @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.

            T Offline
            T Offline
            titan99_
            wrote on last edited by titan99_
            #5

            @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.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved