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. [solved]Setting Images in QListWidget
Forum Updated to NodeBB v4.3 + New Features

[solved]Setting Images in QListWidget

Scheduled Pinned Locked Moved General and Desktop
15 Posts 2 Posters 7.5k 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi,

    From a quick overview, you never set your items in your QListWidget

    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
    • V Offline
      V Offline
      venkatesh
      wrote on last edited by
      #3

      Hi,

      Thanks for your response, i did add it after posting here
      But, i am confused how to do it.

      When i created a pointer to the class, or create an object nothing happens. How can i set the items in the listWidget ?

      I tried

      @

      listWidget *list;
      list->addItem(Image);

      @

      also just

      @

      addItem(Image);

      @

      Both are not working, how else can i set the items?

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

        Did you check that you set a valid pixmap on your icon ?

        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
        • V Offline
          V Offline
          venkatesh
          wrote on last edited by
          #5

          Hi,

          When i directly add the code in the listWidget class its working, it just executes immediately when i run the ui without main window being displayed. But when i try using the signal, slot in another class as such

          @

          connect(ui->ImportImages,SIGNAL(clicked()),&listObject_, SLOT(setData_()));
          

          @

          The file dialog opens but the images are not displayed in listWidget. I don't know whats the problem

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

            Can you post your constructor code (the one containing this connect statement) ?

            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
            • V Offline
              V Offline
              venkatesh
              wrote on last edited by
              #7

              @ connect(ui->ImportImages,SIGNAL(clicked()),&listObject_, SLOT(setData_())); @

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

                Not just the same connect statement, the complete constructor code

                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
                • V Offline
                  V Offline
                  venkatesh
                  wrote on last edited by
                  #9

                  @

                  ImageRegistration::ImageRegistration(QWidget *parent) :
                  QWidget(parent),
                  ui(new Ui::ImageRegistration)
                  {

                  ui->setupUi(this);
                  ui->ExportTransformationMatrix->setStyleSheet("border-style:inset");
                  ui->ExportTransformationMatrix->setStyleSheet("border-width: 2px");
                  
                  
                  ui->ManualRegistrationView->setStyleSheet(" border: 2px solid rgb(130,170,245)");
                  ui->StationaryImageView->setStyleSheet(" border: 2px solid rgb(130,170,245)");
                  ui->MovingImageView->setStyleSheet("border: 2px solid rgb(130,170,245)");
                  ui->ZoomImage->setStyleSheet("border: 2px solid black ");
                  
                  connect(ui->ZoomImage,SIGNAL(valueChanged(int)),this,SLOT(updateTransform()));
                  connect(ui->RotateImage,SIGNAL(valueChanged(int)),this,SLOT(updateTransform()));
                  connect(ui->ImportImages,SIGNAL(clicked()),&listObject_, SLOT(setData_()));
                  

                  }

                  @

                  I have initialised the object in header as @ listWidget listObject_; @

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

                    You don't show listObject_.

                    And since it's not in any layout, it won't be automatically placed/resized for you

                    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
                    • V Offline
                      V Offline
                      venkatesh
                      wrote on last edited by
                      #11

                      Hi,

                      Thanks for the response. When i added
                      @listObject_.show(); @ its shown in separate window, how can i make it visible in listWidget? I thought when we create an object, and apply the slot it would be placed in the class from which object is created. If we have to specify it manually is there a way to do it?

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

                        It won't automagically be layouted because you create it in a widget.

                        You need to either add it to your ui file (using designer) or add it to your widgets layout.

                        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
                        • V Offline
                          V Offline
                          venkatesh
                          wrote on last edited by
                          #13

                          Hi,
                          I have already promoted listWidget class to the designer. How can i promote its object ? I tried the following but no use.How else can i add it to the ui

                          @

                          ui->ImageList=&listObject;
                          ui->ImageList->show();

                          @

                          1 Reply Last reply
                          0
                          • V Offline
                            V Offline
                            venkatesh
                            wrote on last edited by
                            #14

                            Hi,

                            Solved this problem using the following in

                            ImageRegistration constructor

                            @
                            listWidget *listObject=ui->ImageList;
                            @

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

                              This is not a clean solution.
                              Remove listWidget from your code and only call ui->ImageList. You are starting evil things there (have a look about at the QObject documentation to know why copying QObject/QObject derived class is not allowed)

                              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