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. How to make a comment bar in Qt?
QtWS25 Last Chance

How to make a comment bar in Qt?

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 3 Posters 365 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.
  • W Offline
    W Offline
    Wgxzzzzzzc
    wrote on last edited by
    #1

    I want make a comment bar where every review comes from the database. My idea is that i use Model/View to make it, Every review will be put in a view item.But i don't kow how to make each view item to adapt its height according to the number of review. Would anyone like to help me with the answer?

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      Im not sure how a comment bar looks like but
      cant you just adjust each row's height ?

      1 Reply Last reply
      1
      • W Offline
        W Offline
        Wgxzzzzzzc
        wrote on last edited by Wgxzzzzzzc
        #3

        @mrjj I can adjust ervery item's height in QTreeView, but ervery item can't switch row automatically. this is my project.
        捕获.PNG

        mrjjM 1 Reply Last reply
        0
        • W Wgxzzzzzzc

          @mrjj I can adjust ervery item's height in QTreeView, but ervery item can't switch row automatically. this is my project.
          捕获.PNG

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Wgxzzzzzzc said in How to make a comment bar in Qt?:

          • item can't switch row automatically

          Im not sure what you mean ?
          You mean if text is very long then it wont word break within the cell or what do you mean with
          switch row ?

          W 1 Reply Last reply
          1
          • mrjjM mrjj

            @Wgxzzzzzzc said in How to make a comment bar in Qt?:

            • item can't switch row automatically

            Im not sure what you mean ?
            You mean if text is very long then it wont word break within the cell or what do you mean with
            switch row ?

            W Offline
            W Offline
            Wgxzzzzzzc
            wrote on last edited by
            #5

            @mrjj my mean is that i want every view item like this picture. sorry, my english is not good.
            捕获.PNG

            mrjjM 1 Reply Last reply
            0
            • Christian EhrlicherC Online
              Christian EhrlicherC Online
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #6

              So it's a simple QTextEdit?

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              1 Reply Last reply
              2
              • W Wgxzzzzzzc

                @mrjj my mean is that i want every view item like this picture. sorry, my english is not good.
                捕获.PNG

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by mrjj
                #7

                @Wgxzzzzzzc
                Hi
                No problem with the English. i just ask a bit more to make sure i understand.

                Did you try to call view->resizeRowsToContents();
                to have it expand the row ? It should do wordwrap by default.

                W 1 Reply Last reply
                1
                • mrjjM mrjj

                  @Wgxzzzzzzc
                  Hi
                  No problem with the English. i just ask a bit more to make sure i understand.

                  Did you try to call view->resizeRowsToContents();
                  to have it expand the row ? It should do wordwrap by default.

                  W Offline
                  W Offline
                  Wgxzzzzzzc
                  wrote on last edited by
                  #8

                  @mrjj But my view is QTreeView and there isn't an tableWidget in the view. the picture is my code. I just want every view item's behavior like textEdit.
                  捕获.PNG

                  mrjjM 1 Reply Last reply
                  0
                  • W Wgxzzzzzzc

                    @mrjj But my view is QTreeView and there isn't an tableWidget in the view. the picture is my code. I just want every view item's behavior like textEdit.
                    捕获.PNG

                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    @Wgxzzzzzzc
                    Ah sorry its a treeView. I read table :)

                    try
                    ui->mytreeview->header()->resizeSections(QHeaderView::ResizeToContents);

                    1 Reply Last reply
                    0
                    • W Offline
                      W Offline
                      Wgxzzzzzzc
                      wrote on last edited by
                      #10

                      @mrjj I think using QListWidget and customizing my item is a good way. but still thank you very much!

                      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