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. QTreeView inline edit alignment problem
Forum Updated to NodeBB v4.3 + New Features

QTreeView inline edit alignment problem

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 362 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.
  • jronaldJ Offline
    jronaldJ Offline
    jronald
    wrote on last edited by jronald
    #1

    PROBLEM
    Screenshot_20240328_120623.png

    As shown in the screenshot, column "2018" is right aligned.
    When editing an empty cell in this column, the inline edit shows as in the screenshot.
    I think the inline edit should match the cell size properly.

    ENV
    Linux
    Qt 6.6.2

    JonBJ 1 Reply Last reply
    0
    • jronaldJ jronald

      PROBLEM
      Screenshot_20240328_120623.png

      As shown in the screenshot, column "2018" is right aligned.
      When editing an empty cell in this column, the inline edit shows as in the screenshot.
      I think the inline edit should match the cell size properly.

      ENV
      Linux
      Qt 6.6.2

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @jronald
      Which of the following are you asking about/not liking:

      • The line edit is not as wide as the 2018 (or 2017) column?
      • The line edit's content is left- not right-aligned?
      • The line edit for the 2018 column appears in the 2017 column (apparently)?
      jronaldJ 1 Reply Last reply
      0
      • JonBJ JonB

        @jronald
        Which of the following are you asking about/not liking:

        • The line edit is not as wide as the 2018 (or 2017) column?
        • The line edit's content is left- not right-aligned?
        • The line edit for the 2018 column appears in the 2017 column (apparently)?
        jronaldJ Offline
        jronaldJ Offline
        jronald
        wrote on last edited by jronald
        #3

        @JonB said in QTableView inline edit alignment problem:

        @jronald
        Which of the following are you asking about/not liking:

        • The line edit is not as wide as the 2018 (or 2017) column?

        For column "2018",

        1. the width of the edit is not as wide as the column
        2. the offset of the edit is not as expected, it should on the cell in column "2018", but it's in column "2017" now
        • The line edit's content is left- not right-aligned?

        right aligned

        • The line edit for the 2018 column appears in the 2017 column (apparently)?

        Yes

        JonBJ 1 Reply Last reply
        0
        • jronaldJ jronald

          @JonB said in QTableView inline edit alignment problem:

          @jronald
          Which of the following are you asking about/not liking:

          • The line edit is not as wide as the 2018 (or 2017) column?

          For column "2018",

          1. the width of the edit is not as wide as the column
          2. the offset of the edit is not as expected, it should on the cell in column "2018", but it's in column "2017" now
          • The line edit's content is left- not right-aligned?

          right aligned

          • The line edit for the 2018 column appears in the 2017 column (apparently)?

          Yes

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @jronald
          Well let's start with: I have never seen the edit widget appear anywhere else than in its own column, certainly not in another column. So I suggest you start by discovering why this is for you (e.g. try a minimal case in a fresh application).

          Look at your table view's itemDelegate(). You can access the line edit in QAbstractItemDelegate::createEditor(), e.g. set it to align right or affect its width. You may have to derive your own class from QStyledItemDelegate and set the table view to use that.

          jronaldJ 1 Reply Last reply
          0
          • JonBJ JonB

            @jronald
            Well let's start with: I have never seen the edit widget appear anywhere else than in its own column, certainly not in another column. So I suggest you start by discovering why this is for you (e.g. try a minimal case in a fresh application).

            Look at your table view's itemDelegate(). You can access the line edit in QAbstractItemDelegate::createEditor(), e.g. set it to align right or affect its width. You may have to derive your own class from QStyledItemDelegate and set the table view to use that.

            jronaldJ Offline
            jronaldJ Offline
            jronald
            wrote on last edited by
            #5

            @JonB
            It's hard to write a simple demo to reproduce the problem.
            But I find that the width of inline edit changes dynamically to fit text.

            JonBJ 1 Reply Last reply
            0
            • jronaldJ jronald

              @JonB
              It's hard to write a simple demo to reproduce the problem.
              But I find that the width of inline edit changes dynamically to fit text.

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by JonB
              #6

              @jronald
              It should not be hard at all, just a QTableView with a 2 column model. If it is hard to reproduce then something is going on/others will not be able to repro. As I say, I have used it many times with no problems, and don't you think other people would report if every time they tried to edit from a QTableView it went as badly wrong as this?

              Anyway, if it really does this (and I think you have something wrong in your code) I told you what you can do about it.

              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