Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved Qframe lines and QTextEdit scrollbar are not drawn correctly

    General and Desktop
    high dpi
    3
    5
    302
    Loading More Posts
    • 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
      titan99_ last edited by titan99_

      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 Reply Quote 0
      • gde23
        gde23 last edited by

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

        T 1 Reply Last reply Reply Quote 0
        • T
          titan99_ @gde23 last edited by

          @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 Reply Quote 0
          • B
            Bonnie @titan99_ last edited by

            @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 Reply Quote 1
            • T
              titan99_ @Bonnie last edited by titan99_

              @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 Reply Quote 0
              • First post
                Last post