Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Led Like buttons/Widgets
Qt 6.12 LTS is out! See what's new in the release blog

Led Like buttons/Widgets

Scheduled Pinned Locked Moved General and Desktop
39 Posts 8 Posters 59.2k Views 4 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.
  • B Bruschetta

    @mrjj
    you have been fast as lightning! And it's working! Thahks a lot!

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

    @Bruschetta
    Super :)

    1 Reply Last reply
    1
    • mrjjM mrjj

      @SGaist
      Funny enough I also found that ;)
      Its Qt4-ish and needed to be updated to new plugin export macros and includes for designer
      interface. the pro file also had old keywords and some more stuff needed.

      Here is version that can compile on Windows Qt5.7.
      https://www.dropbox.com/s/38endyfoexb28nd/QLeds57.zip?dl=0

      B Offline
      B Offline
      BlackDogWhite
      wrote on last edited by
      #21

      @mrjj You have been very helpful to @Bruschetta and I'm wondering if you will go a little further.

      The Qleds57.zip file is no longer in your drop box. Would you mind terribly putting up a copy again? Or a 5.10 version?

      I'm trying to walk through this as a beginner and keep running into roadblocks.

      mrjjM 1 Reply Last reply
      0
      • B BlackDogWhite

        @mrjj You have been very helpful to @Bruschetta and I'm wondering if you will go a little further.

        The Qleds57.zip file is no longer in your drop box. Would you mind terribly putting up a copy again? Or a 5.10 version?

        I'm trying to walk through this as a beginner and keep running into roadblocks.

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

        @BlackDogWhite
        Surely
        Here is similar sample
        https://www.dropbox.com/sh/mnaipp7apodqp0d/AABkpILwRICtBxd-5lK0CcUSa?dl=0

        Make sure to open UseTheLeds.pro
        in the UseTheLeds subfolder.
        It show a led using .pri inclusion. That is it compiles the leds into the project.

        There is also qledplugin.pro that compiles it as a plugin.
        Note that to use it as a plugin, you need the visual studio compiler to make it loadable by
        Creator. (mingw wont work)

        Using .pri inclusion, you dont have a plugin, but can use promotion. ( as UseTheLeds.pro shows)

        While a plugin, offers design time settings of properties, you can access the promoted led in code
        using ui->ledname and hence get almost the same.

        Let me know if you want to create a plugin. I didnt test if that part just works
        but UseTheLeds surely runs on 5.10

        B 1 Reply Last reply
        1
        • mrjjM mrjj

          @BlackDogWhite
          Surely
          Here is similar sample
          https://www.dropbox.com/sh/mnaipp7apodqp0d/AABkpILwRICtBxd-5lK0CcUSa?dl=0

          Make sure to open UseTheLeds.pro
          in the UseTheLeds subfolder.
          It show a led using .pri inclusion. That is it compiles the leds into the project.

          There is also qledplugin.pro that compiles it as a plugin.
          Note that to use it as a plugin, you need the visual studio compiler to make it loadable by
          Creator. (mingw wont work)

          Using .pri inclusion, you dont have a plugin, but can use promotion. ( as UseTheLeds.pro shows)

          While a plugin, offers design time settings of properties, you can access the promoted led in code
          using ui->ledname and hence get almost the same.

          Let me know if you want to create a plugin. I didnt test if that part just works
          but UseTheLeds surely runs on 5.10

          B Offline
          B Offline
          BlackDogWhite
          wrote on last edited by
          #23

          @mrjj Thank you for sharing those files. I was able to open the UseTheLeds project, run it, modify it and all was cool.

          But then I tried to add another instance of the qLed, both by promotion (drag a Containers->Widget onto the form; rtClk->Promote ) and by coping the already working qLed object. Neither of these worked. Adding to the MainWindow constructor

          ui->qLed_2->setShape(QLed::Circle);  // the "copied" version of qLed
          ui->MyQled->setShape(QLed::Circle); // the promoted container widget
          
          

          would cause the compile to fail because neither qLed_2 nor MyQled were members of Ui::MainWindow.

          Obviously I've skipped an important step. Probably something to do with ui_mainwindow.h. Am I supposed to edit that manually (I don't think so, but it's not getting updated automatically)?

          Hints??

          B 1 Reply Last reply
          0
          • B BlackDogWhite

            @mrjj Thank you for sharing those files. I was able to open the UseTheLeds project, run it, modify it and all was cool.

            But then I tried to add another instance of the qLed, both by promotion (drag a Containers->Widget onto the form; rtClk->Promote ) and by coping the already working qLed object. Neither of these worked. Adding to the MainWindow constructor

            ui->qLed_2->setShape(QLed::Circle);  // the "copied" version of qLed
            ui->MyQled->setShape(QLed::Circle); // the promoted container widget
            
            

            would cause the compile to fail because neither qLed_2 nor MyQled were members of Ui::MainWindow.

            Obviously I've skipped an important step. Probably something to do with ui_mainwindow.h. Am I supposed to edit that manually (I don't think so, but it's not getting updated automatically)?

            Hints??

            B Offline
            B Offline
            BlackDogWhite
            wrote on last edited by
            #24

            @mrjj
            ohhhh, I must not have something set up properly, maybe because this was just a demo. But when I add stuff to the ui, the ui_mainwindow.h file is created up and over in a build-UseTheLeds-Desktop_blah_blah-Debug directory. So that .h file has references to MyQled and qLed_2.

            Must be something screwed up in my environment.

            mrjjM 1 Reply Last reply
            0
            • B BlackDogWhite

              @mrjj
              ohhhh, I must not have something set up properly, maybe because this was just a demo. But when I add stuff to the ui, the ui_mainwindow.h file is created up and over in a build-UseTheLeds-Desktop_blah_blah-Debug directory. So that .h file has references to MyQled and qLed_2.

              Must be something screwed up in my environment.

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

              @BlackDogWhite
              hi, nope something up with usetheleds demo as copying
              the promoted several time didnt show many lights.
              Ill will report back when i have a look at it :)

              B 1 Reply Last reply
              0
              • mrjjM mrjj

                @BlackDogWhite
                hi, nope something up with usetheleds demo as copying
                the promoted several time didnt show many lights.
                Ill will report back when i have a look at it :)

                B Offline
                B Offline
                BlackDogWhite
                wrote on last edited by
                #26

                @mrjj well, it may also be my environment, sadly. I'm trying to figure out Qt, both on the PC and on a Raspberry Pi 3, using MS Visual Studio (which I'm pretty familiar with), along with QT VS Tools and VisualGDB.

                • I can get your demo (UseTheLeds) working under Qt Creator (except for the above referenced problem) and displaying on the PC

                • I also have a working GUI program developed on the PC (with VS, Qt VS Tools, and VisualGDB) that runs both on the PC and squirts down to the Pi.

                • But trying to add the Qled code to the working GUI program breaks everything, possibly in part because the cross compiler chain (c:\sysgcc\raspberry...) cannot find QtSvg includes. When I search for QtSvg, I find it but only in a qt4 dir chain (SysGCC\raspberry\arm-linux-gnueabihf\sysroot\usr\include\qt4...)

                Ouch, I'm getting a headache!

                mrjjM 1 Reply Last reply
                0
                • B BlackDogWhite

                  @mrjj well, it may also be my environment, sadly. I'm trying to figure out Qt, both on the PC and on a Raspberry Pi 3, using MS Visual Studio (which I'm pretty familiar with), along with QT VS Tools and VisualGDB.

                  • I can get your demo (UseTheLeds) working under Qt Creator (except for the above referenced problem) and displaying on the PC

                  • I also have a working GUI program developed on the PC (with VS, Qt VS Tools, and VisualGDB) that runs both on the PC and squirts down to the Pi.

                  • But trying to add the Qled code to the working GUI program breaks everything, possibly in part because the cross compiler chain (c:\sysgcc\raspberry...) cannot find QtSvg includes. When I search for QtSvg, I find it but only in a qt4 dir chain (SysGCC\raspberry\arm-linux-gnueabihf\sysroot\usr\include\qt4...)

                  Ouch, I'm getting a headache!

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

                  @BlackDogWhite
                  Hi
                  Do you need it to be very scale able ?
                  Else we could use png for the leds if getting the SVG module to the Pi is
                  difficult.

                  However, there was something odd wiht the sample. i will link a new one here as soon as its weekend :)

                  B 1 Reply Last reply
                  0
                  • mrjjM mrjj

                    @BlackDogWhite
                    Hi
                    Do you need it to be very scale able ?
                    Else we could use png for the leds if getting the SVG module to the Pi is
                    difficult.

                    However, there was something odd wiht the sample. i will link a new one here as soon as its weekend :)

                    B Offline
                    B Offline
                    BlackDogWhite
                    wrote on last edited by
                    #28

                    @mrjj First off, I'm up for any help someone is willing to offer. A revised version would be very useful, if only to study the differences and learn something else about how all this works.

                    I'm going to look, hopefully this afternoon, where my cross compiler install went wrong. Maybe I can get that upgraded to Qt5 so the SVG stuff works. But I certainly wouldn't mind seeing how it would work with PNG's!

                    mrjjM 1 Reply Last reply
                    0
                    • B BlackDogWhite

                      @mrjj First off, I'm up for any help someone is willing to offer. A revised version would be very useful, if only to study the differences and learn something else about how all this works.

                      I'm going to look, hopefully this afternoon, where my cross compiler install went wrong. Maybe I can get that upgraded to Qt5 so the SVG stuff works. But I certainly wouldn't mind seeing how it would work with PNG's!

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

                      @BlackDogWhite

                      Hi
                      Here is other sample that allows copy paste of promoted widget.
                      Im not sure what was up with the other. the ui file seemed stale.

                      Anyway, this works. the go button show random shape and color.
                      I have included only bare minimum of qled files to work.

                      alt text

                      https://www.dropbox.com/s/kfti0otv9ez9u28/Myleds.zip?dl=0

                      B V 2 Replies Last reply
                      1
                      • mrjjM mrjj

                        @BlackDogWhite

                        Hi
                        Here is other sample that allows copy paste of promoted widget.
                        Im not sure what was up with the other. the ui file seemed stale.

                        Anyway, this works. the go button show random shape and color.
                        I have included only bare minimum of qled files to work.

                        alt text

                        https://www.dropbox.com/s/kfti0otv9ez9u28/Myleds.zip?dl=0

                        B Offline
                        B Offline
                        BlackDogWhite
                        wrote on last edited by
                        #30

                        @mrjj Thanks MrJJ. I was able to copy your code and create a project from scratch using the QLed class to render a button. On the UI I drag in a Widget object and promote it to QLed. It shows up just fine. This is all in Qt Creator 4.5.1, Qt 5.10.1 and Visual Studio 2013 for the compiler.

                        I was also able to get it to work on the Raspberry Pi using VS 2013 along with Qt VS Tools and VisualGDB added in.

                        Still have quite a bit to learn, never having done Qt or Pi before. But with your help I've made good progress. Maybe I'll get bold and actually try to get the plugin to work as well, but that's pretty low priority.

                        Thank you for all your help. You da man!
                        Ron

                        mrjjM 1 Reply Last reply
                        1
                        • B BlackDogWhite

                          @mrjj Thanks MrJJ. I was able to copy your code and create a project from scratch using the QLed class to render a button. On the UI I drag in a Widget object and promote it to QLed. It shows up just fine. This is all in Qt Creator 4.5.1, Qt 5.10.1 and Visual Studio 2013 for the compiler.

                          I was also able to get it to work on the Raspberry Pi using VS 2013 along with Qt VS Tools and VisualGDB added in.

                          Still have quite a bit to learn, never having done Qt or Pi before. But with your help I've made good progress. Maybe I'll get bold and actually try to get the plugin to work as well, but that's pretty low priority.

                          Thank you for all your help. You da man!
                          Ron

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

                          @BlackDogWhite
                          Super :)
                          well crosscompiling is not easy. So good work.
                          Since you already have visual studio, it might not be huge work to get the plugin running
                          but in this case it offer not so much besides seeing the leds in designer and setting type and
                          color directly in Designer. ( you could also do that with dynamic properties as they are
                          added to the actual widget type also when using promotion)

                          1 Reply Last reply
                          0
                          • mrjjM mrjj

                            @BlackDogWhite

                            Hi
                            Here is other sample that allows copy paste of promoted widget.
                            Im not sure what was up with the other. the ui file seemed stale.

                            Anyway, this works. the go button show random shape and color.
                            I have included only bare minimum of qled files to work.

                            alt text

                            https://www.dropbox.com/s/kfti0otv9ez9u28/Myleds.zip?dl=0

                            V Offline
                            V Offline
                            viniltc
                            wrote on last edited by
                            #32

                            @mrjj

                            I'm a beginner, I also came across the same problem to add a status LED in my GUI. @mrjj : unable to download the code from the mentioned link. It will be very useful if you can summarize the procedure.

                            many thanks

                            mrjjM 1 Reply Last reply
                            0
                            • V viniltc

                              @mrjj

                              I'm a beginner, I also came across the same problem to add a status LED in my GUI. @mrjj : unable to download the code from the mentioned link. It will be very useful if you can summarize the procedure.

                              many thanks

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

                              @viniltc
                              Hi
                              Link is still ok
                              https://www.dropbox.com/s/kfti0otv9ez9u28/Myleds.zip?dl=0
                              just tested

                              V 1 Reply Last reply
                              1
                              • mrjjM mrjj

                                @viniltc
                                Hi
                                Link is still ok
                                https://www.dropbox.com/s/kfti0otv9ez9u28/Myleds.zip?dl=0
                                just tested

                                V Offline
                                V Offline
                                viniltc
                                wrote on last edited by viniltc
                                #34

                                @mrjj Thanks a lot.
                                I just noticed 'layout' feature is disabled for QLed widget.
                                Please find below the screenshot. How can I enable Layout to QLed class?
                                0_1565101152046_Capture.JPG

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

                                  Hi
                                  You can right-click it and apply a layout.
                                  Its not disabled. it shows no layout is assigned.
                                  However,why do you want to have layout in it ?
                                  It would be more normal to put the led and the other widget in a separate layout.

                                  V 1 Reply Last reply
                                  2
                                  • mrjjM mrjj

                                    Hi
                                    You can right-click it and apply a layout.
                                    Its not disabled. it shows no layout is assigned.
                                    However,why do you want to have layout in it ?
                                    It would be more normal to put the led and the other widget in a separate layout.

                                    V Offline
                                    V Offline
                                    viniltc
                                    wrote on last edited by
                                    #36

                                    @mrjj
                                    Thanks a lot for the clarification. I'm aiming for a fully resizable GUI, that's why I need a layout. Like for example:
                                    0_1565269885069_Capture.JPG (the moment it's without a layout)
                                    But when I apply a grid layout to the GUI, I'm kind of struggling to get its widgets (especially LED) at its place!

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

                                      Hi
                                      Well you add a layout to the parent. (the window)
                                      and then insert the Led and buttons into that layout.
                                      so if you resize the window, they will all follow.

                                      update
                                      Ahh first saw now, you did use a grid layout, so it was about the position.
                                      Luckily @Pl45m4 to the rescue :)

                                      1 Reply Last reply
                                      0
                                      • Pl45m4P Offline
                                        Pl45m4P Offline
                                        Pl45m4
                                        wrote on last edited by Pl45m4
                                        #38

                                        @viniltc

                                        To realize the layout, like it is shown in your image, you dont need a GridLayout. Two VerticalLayouts paired with one HorizontalLayout should work.

                                        0_1565275743067_LED.png
                                        0_1565275834059_layout.png


                                        If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                                        ~E. W. Dijkstra

                                        V 1 Reply Last reply
                                        3
                                        • Pl45m4P Pl45m4

                                          @viniltc

                                          To realize the layout, like it is shown in your image, you dont need a GridLayout. Two VerticalLayouts paired with one HorizontalLayout should work.

                                          0_1565275743067_LED.png
                                          0_1565275834059_layout.png

                                          V Offline
                                          V Offline
                                          viniltc
                                          wrote on last edited by
                                          #39

                                          @pl45m4
                                          Thanks a lot for the clarification :)

                                          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
                                          • Unsolved