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. Add textEdits on listWidget

Add textEdits on listWidget

Scheduled Pinned Locked Moved Solved General and Desktop
qt5.5qt4qt 5.7listwidget
15 Posts 3 Posters 7.1k 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.
  • K Kinesis
    25 Jun 2018, 04:34

    @jsulm
    Because I am trying to display image icons,videos and textedits on listwidget which is a layout . Now I can display images on listwidget . I need to show textedits.Thats why.BTW that's for my own application project.Thanks

    J Offline
    J Offline
    jsulm
    Lifetime Qt Champion
    wrote on 25 Jun 2018, 04:40 last edited by
    #4

    @Kinesis QListWidget isn't a layout, it is a widget. I don't think you can add text edit easily to QListWidget, maybe you can if you subclass QListWidgetItem. Does it really need to be text edit (I guess you mean QLineEdit?)? Or is it only read-only text?

    https://forum.qt.io/topic/113070/qt-code-of-conduct

    K 1 Reply Last reply 25 Jun 2018, 04:53
    0
    • J jsulm
      25 Jun 2018, 04:40

      @Kinesis QListWidget isn't a layout, it is a widget. I don't think you can add text edit easily to QListWidget, maybe you can if you subclass QListWidgetItem. Does it really need to be text edit (I guess you mean QLineEdit?)? Or is it only read-only text?

      K Offline
      K Offline
      Kinesis
      wrote on 25 Jun 2018, 04:53 last edited by Kinesis
      #5

      @jsulm
      For QLineEdit , I tested it . I found that it is not suitable because QLineEdit is 1 line text editor . I need to show text with multiple lines .And the text should be read-only text. That's why text edit or text browse is the most suitable for me.
      So is there another widget that textedits can be added ??

      J 1 Reply Last reply 25 Jun 2018, 05:10
      0
      • K Kinesis
        25 Jun 2018, 04:53

        @jsulm
        For QLineEdit , I tested it . I found that it is not suitable because QLineEdit is 1 line text editor . I need to show text with multiple lines .And the text should be read-only text. That's why text edit or text browse is the most suitable for me.
        So is there another widget that textedits can be added ??

        J Offline
        J Offline
        jsulm
        Lifetime Qt Champion
        wrote on 25 Jun 2018, 05:10 last edited by
        #6

        @Kinesis If the text is read-only why not simply add it using http://doc.qt.io/qt-5/qlistwidgetitem.html#QListWidgetItem-2 ?

        QListWidgetItem *item = new QListWidgetItem(icon, "some text");
        listWidget->addItem(item);
        

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        K 1 Reply Last reply 25 Jun 2018, 05:25
        0
        • J jsulm
          25 Jun 2018, 05:10

          @Kinesis If the text is read-only why not simply add it using http://doc.qt.io/qt-5/qlistwidgetitem.html#QListWidgetItem-2 ?

          QListWidgetItem *item = new QListWidgetItem(icon, "some text");
          listWidget->addItem(item);
          
          K Offline
          K Offline
          Kinesis
          wrote on 25 Jun 2018, 05:25 last edited by Kinesis
          #7

          @jsulm
          read-only text means text inside textedit is read only.plz take alook my code and u will understand clearly.

          for(const QFileInfo & finfo: directory.entryInfoList()){
              m_textEdit = new QTextEdit;
              QFile data(finfo.absoluteFilePath()) ;
              data.open(QIODevice::ReadOnly);
              QTextStream stream(&data);
              QString content = stream.readAll();
              data.close();
              
              
              m_textEdit->setText(content);
              m_textEdit->show();
              ui->listWidget->addItem(m_textEdit);
          }
          

          The problem is that I cant add textEdit on listWidget easily .

          J 1 Reply Last reply 25 Jun 2018, 05:29
          0
          • K Kinesis
            25 Jun 2018, 05:25

            @jsulm
            read-only text means text inside textedit is read only.plz take alook my code and u will understand clearly.

            for(const QFileInfo & finfo: directory.entryInfoList()){
                m_textEdit = new QTextEdit;
                QFile data(finfo.absoluteFilePath()) ;
                data.open(QIODevice::ReadOnly);
                QTextStream stream(&data);
                QString content = stream.readAll();
                data.close();
                
                
                m_textEdit->setText(content);
                m_textEdit->show();
                ui->listWidget->addItem(m_textEdit);
            }
            

            The problem is that I cant add textEdit on listWidget easily .

            J Offline
            J Offline
            jsulm
            Lifetime Qt Champion
            wrote on 25 Jun 2018, 05:29 last edited by jsulm
            #8

            @Kinesis Sorry, but I still don't get why you need a QTextEdit? QListWidgetItem already can show text:

            for(const QFileInfo & finfo: directory.entryInfoList()){
                QFile data(finfo.absoluteFilePath()) ;
                data.open(QIODevice::ReadOnly);
                QTextStream stream(&data);
                QString content = stream.readAll();
                data.close();
                
                QListWidgetItem *m_textEdit = new QListWidgetItem(content);
                ui->listWidget->addItem(m_textEdit);
            }
            

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            K 1 Reply Last reply 25 Jun 2018, 05:43
            0
            • J jsulm
              25 Jun 2018, 05:29

              @Kinesis Sorry, but I still don't get why you need a QTextEdit? QListWidgetItem already can show text:

              for(const QFileInfo & finfo: directory.entryInfoList()){
                  QFile data(finfo.absoluteFilePath()) ;
                  data.open(QIODevice::ReadOnly);
                  QTextStream stream(&data);
                  QString content = stream.readAll();
                  data.close();
                  
                  QListWidgetItem *m_textEdit = new QListWidgetItem(content);
                  ui->listWidget->addItem(m_textEdit);
              }
              
              K Offline
              K Offline
              Kinesis
              wrote on 25 Jun 2018, 05:43 last edited by
              #9

              @jsulm
              Thanks for your code but I want to show textedits on list widget like that image0_1529905294738_file.png
              BTW I really appreciate your help :)

              J 1 Reply Last reply 25 Jun 2018, 06:23
              0
              • K Kinesis
                25 Jun 2018, 05:43

                @jsulm
                Thanks for your code but I want to show textedits on list widget like that image0_1529905294738_file.png
                BTW I really appreciate your help :)

                J Offline
                J Offline
                jsulm
                Lifetime Qt Champion
                wrote on 25 Jun 2018, 06:23 last edited by
                #10

                @Kinesis But what is wrong with my code? It should show the text inside the QListWidget.
                Your picture shows each text in its own window - is this what you want?!

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                K 1 Reply Last reply 25 Jun 2018, 06:26
                0
                • J jsulm
                  25 Jun 2018, 06:23

                  @Kinesis But what is wrong with my code? It should show the text inside the QListWidget.
                  Your picture shows each text in its own window - is this what you want?!

                  K Offline
                  K Offline
                  Kinesis
                  wrote on 25 Jun 2018, 06:26 last edited by
                  #11

                  @jsulm
                  Yes , I want to show text with separate textedit .

                  J 1 Reply Last reply 25 Jun 2018, 06:28
                  0
                  • K Kinesis
                    25 Jun 2018, 06:26

                    @jsulm
                    Yes , I want to show text with separate textedit .

                    J Offline
                    J Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on 25 Jun 2018, 06:28 last edited by
                    #12

                    @Kinesis My question was whether you want to show it in a WINDOW like in your picture.
                    And can you explain why you need a QTextEdit to show read-only text if you already can show text in QListWidget? I really don't understand that.

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    K 1 Reply Last reply 25 Jun 2018, 06:42
                    0
                    • J jsulm
                      25 Jun 2018, 06:28

                      @Kinesis My question was whether you want to show it in a WINDOW like in your picture.
                      And can you explain why you need a QTextEdit to show read-only text if you already can show text in QListWidget? I really don't understand that.

                      K Offline
                      K Offline
                      Kinesis
                      wrote on 25 Jun 2018, 06:42 last edited by Kinesis
                      #13

                      @jsulm
                      Here is my sample GUI that I am planning to create . In this sample U will see that all videos ,images and textedits will be showed on same widget! Thats why I need to use textedit 0_1529908949075_AA.png

                      D 1 Reply Last reply 26 Jun 2018, 05:55
                      0
                      • K Kinesis
                        25 Jun 2018, 06:42

                        @jsulm
                        Here is my sample GUI that I am planning to create . In this sample U will see that all videos ,images and textedits will be showed on same widget! Thats why I need to use textedit 0_1529908949075_AA.png

                        D Offline
                        D Offline
                        Devopia53
                        wrote on 26 Jun 2018, 05:55 last edited by Devopia53
                        #14

                        @Kinesis

                        like this(only example):

                        ui->listWidget->setFlow(QListView::LeftToRight);
                        ui->listWidget->setGridSize(QSize(110, 90));
                        ui->listWidget->setResizeMode(QListView::Adjust);
                        ui->listWidget->setViewMode(QListView::ListMode);
                        ui->listWidget->setWrapping(true);
                        
                        for (const QFileInfo &finfo : directory.entryInfoList()) {
                            [...]
                            auto    item = new QListWidgetItem("", ui->listWidget);
                            auto    text = new QTextEdit(content);
                            text->setMinimumSize(100, 80);
                            ui->listWidget->setItemWidget(item, text);
                        }
                        
                        K 1 Reply Last reply 26 Jun 2018, 06:42
                        1
                        • D Devopia53
                          26 Jun 2018, 05:55

                          @Kinesis

                          like this(only example):

                          ui->listWidget->setFlow(QListView::LeftToRight);
                          ui->listWidget->setGridSize(QSize(110, 90));
                          ui->listWidget->setResizeMode(QListView::Adjust);
                          ui->listWidget->setViewMode(QListView::ListMode);
                          ui->listWidget->setWrapping(true);
                          
                          for (const QFileInfo &finfo : directory.entryInfoList()) {
                              [...]
                              auto    item = new QListWidgetItem("", ui->listWidget);
                              auto    text = new QTextEdit(content);
                              text->setMinimumSize(100, 80);
                              ui->listWidget->setItemWidget(item, text);
                          }
                          
                          K Offline
                          K Offline
                          Kinesis
                          wrote on 26 Jun 2018, 06:42 last edited by
                          #15

                          @Devopia53
                          it works! , Thanks alot

                          1 Reply Last reply
                          0

                          13/15

                          25 Jun 2018, 06:42

                          • Login

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