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 add QLabel or set text custom into QListWidget?
Forum Updated to NodeBB v4.3 + New Features

How to add QLabel or set text custom into QListWidget?

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 2 Posters 1.6k Views 1 Watching
  • 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.
  • Hayden HarberH Offline
    Hayden HarberH Offline
    Hayden Harber
    wrote on last edited by Hayden Harber
    #1

    Hello, as you will see in the photo, I would like to add QLabel to the marked place. But I couldn't do it, I found this;

    QListView::item:text {
    color: #a87272;
    position: relative;
    top: 5px; 
    left: 5px;
    }
    

    026f2760-d490-47a9-b98e-5b206960d0de-image.png
    I am doing this but top and left are not working I hope you understand what I want, please help.

    1 Reply Last reply
    0
    • Hayden HarberH Offline
      Hayden HarberH Offline
      Hayden Harber
      wrote on last edited by
      #2

      Someone help me? Please...

      1 Reply Last reply
      0
      • Hayden HarberH Offline
        Hayden HarberH Offline
        Hayden Harber
        wrote on last edited by
        #3

        @jsulm Can you look, sir?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi and welcome to devnet,

          Please show some patience and allow at least 24 hours to pass before bumping your own thread. This forum is run by volunteers who might not live in the same timezone as you.

          As for your issue, why do you want to add a QLabel there ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • Hayden HarberH Offline
            Hayden HarberH Offline
            Hayden Harber
            wrote on last edited by
            #5

            @SGaist I will put a data in your program with QLabel. It looks good in design.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              You have a QListView, which means you have a model underneath then why not put these data in your model and for custom rendering use QStyledItemDelegate ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              1
              • Hayden HarberH Offline
                Hayden HarberH Offline
                Hayden Harber
                wrote on last edited by
                #7

                i using QListWidgetItem;

                QString webSite = "httpblabla...";
                QString data = DownloadHTTPData(webSite);
                dataLabel = new QLabel(data);
                item = new QListWidgetItem();
                item->setIcon(...);
                if(data == "1")
                {
                item->setIcon(...2);
                item->setText(dataLabel); // Here I want to create a QLabel and bring it to the specified location.
                ui->listWidget->addItem(item);
                }

                (I'm also new to QT.)

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  That's the wrong way to implement it.

                  Since you want to put stuff at specific places, implement a custom QStyledItemDelegate so you'll be able to paint thing where you want to have them.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  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