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. Led Like buttons/Widgets
Forum Updated to NodeBB v4.3 + New Features

Led Like buttons/Widgets

Scheduled Pinned Locked Moved General and Desktop
39 Posts 8 Posters 33.7k 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.
  • SGaistS SGaist

    Hi,

    Just in case, there's QLed that might also be of interest.

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

    @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 B 2 Replies Last reply
    2
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #9

      There's also a LED widget in KDE4, KLed Class Reference.

      • kled.h
      • kled.cpp
      1 Reply Last reply
      5
      • B Offline
        B Offline
        Bruschetta
        wrote on last edited by
        #10

        Guys thank a lot for all your hints. I will find a solution that better fits in my project for sure. Thumbs up for all your answers!

        1 Reply Last reply
        0
        • 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
          Bruschetta
          wrote on last edited by Bruschetta
          #11

          @mrjj
          This is a very interesting plugin , i would like to use it.
          I can build the project i downloaded from your dropbox but i still do not find the plugin into my designer.

          I'm under windows , are there any particular passages i have to do to make it work?
          Thank a lot for your time.

          My QT version is 5.7

          mrjjM 1 Reply Last reply
          0
          • B Bruschetta

            @mrjj
            This is a very interesting plugin , i would like to use it.
            I can build the project i downloaded from your dropbox but i still do not find the plugin into my designer.

            I'm under windows , are there any particular passages i have to do to make it work?
            Thank a lot for your time.

            My QT version is 5.7

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

            @Bruschetta
            Hi.
            Plugins are Dlls. Creator are compiled with Visual Studio. (2013)
            So to load custom plugin, it must be compiled with visual studio and not mingw.
            Then the dll should be copied to "\bin\plugins\designer"

            Alternative you can use the Qleds by Promotion
            http://doc.qt.io/qt-5/designer-using-custom-widgets.html

            Alternative, you can have my VS DLL
            https://www.dropbox.com/s/1f65fzcew6pjm2z/VSqledplugin.zip?dl=0
            Copy to C:\Qt\Tools\QtCreator\bin\plugins\designer
            Disclaimer: Normally I do not recommend downloading DLLS from forums.

            B 1 Reply Last reply
            2
            • mrjjM mrjj

              @Bruschetta
              Hi.
              Plugins are Dlls. Creator are compiled with Visual Studio. (2013)
              So to load custom plugin, it must be compiled with visual studio and not mingw.
              Then the dll should be copied to "\bin\plugins\designer"

              Alternative you can use the Qleds by Promotion
              http://doc.qt.io/qt-5/designer-using-custom-widgets.html

              Alternative, you can have my VS DLL
              https://www.dropbox.com/s/1f65fzcew6pjm2z/VSqledplugin.zip?dl=0
              Copy to C:\Qt\Tools\QtCreator\bin\plugins\designer
              Disclaimer: Normally I do not recommend downloading DLLS from forums.

              B Offline
              B Offline
              Bruschetta
              wrote on last edited by
              #13

              @mrjj
              Your answer is very exaustive, thanks for the heads up!

              mrjjM 1 Reply Last reply
              2
              • B Bruschetta

                @mrjj
                Your answer is very exaustive, thanks for the heads up!

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

                @Bruschetta
                Np.
                I think its needs a .pri file to be complete
                http://doc.qt.io/qt-5/designer-creating-custom-widgets.html
                section "Splitting up the Plugin"
                To make it easy to use in a clean project.
                Then all you need to do is
                include(QLeds.pri)
                to use in a project. Didn't try that yet.

                B 1 Reply Last reply
                2
                • mrjjM mrjj

                  @Bruschetta
                  Np.
                  I think its needs a .pri file to be complete
                  http://doc.qt.io/qt-5/designer-creating-custom-widgets.html
                  section "Splitting up the Plugin"
                  To make it easy to use in a clean project.
                  Then all you need to do is
                  include(QLeds.pri)
                  to use in a project. Didn't try that yet.

                  B Offline
                  B Offline
                  Bruschetta
                  wrote on last edited by Bruschetta
                  #15

                  @mrjj
                  with the dll now i see the widget in the Designer.
                  Anyway if i use it in i have serveral errors.

                  In particular i tried to create the PRI file containing:

                  INCLUDEPATH += $$PWD
                  HEADERS += $$PWD/qled.h
                  SOURCES += $$PWD/qled.cpp
                  
                  
                  

                  That i added to the plugin and the project file

                  Whan i try to compile now i get this error

                  mingw32-make[1]: *** No rule to make target '../../QTProjects-New/Alpha2/qled.cpp', needed by 'debug/qled.o'. Stop.:

                  What i'm doing wrong with this pri files?
                  Is again mingw fault?

                  mrjjM 1 Reply Last reply
                  0
                  • B Bruschetta

                    @mrjj
                    with the dll now i see the widget in the Designer.
                    Anyway if i use it in i have serveral errors.

                    In particular i tried to create the PRI file containing:

                    INCLUDEPATH += $$PWD
                    HEADERS += $$PWD/qled.h
                    SOURCES += $$PWD/qled.cpp
                    
                    
                    

                    That i added to the plugin and the project file

                    Whan i try to compile now i get this error

                    mingw32-make[1]: *** No rule to make target '../../QTProjects-New/Alpha2/qled.cpp', needed by 'debug/qled.o'. Stop.:

                    What i'm doing wrong with this pri files?
                    Is again mingw fault?

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

                    @Bruschetta
                    Hi.
                    seems fine.
                    I have not tried this yet.
                    No, should not be mingw fault. :)

                    maybe we be need
                    QT += QLed

                    Sounds like its not linking the plugin but I not sure if that will do it.

                    I also really want to know how to do this the right way. as I think its very little needed to fully work but
                    not sure what it is.

                    B 1 Reply Last reply
                    1
                    • mrjjM mrjj

                      @Bruschetta
                      Hi.
                      seems fine.
                      I have not tried this yet.
                      No, should not be mingw fault. :)

                      maybe we be need
                      QT += QLed

                      Sounds like its not linking the plugin but I not sure if that will do it.

                      I also really want to know how to do this the right way. as I think its very little needed to fully work but
                      not sure what it is.

                      B Offline
                      B Offline
                      Bruschetta
                      wrote on last edited by Bruschetta
                      #17

                      @mrjj
                      Unfortunately for me .pri files are not working, neither copying the qled.h and qled.cpp into the project.

                      I got those warnings during compile time

                      warning: 'virtual const QMetaObject* QLed::metaObject() const' redeclared without dllimport attribute: previous dllimport ignored
                       warning: 'void QLed::setOffColor(QLed::ledColor)' redeclared without dllimport attribute: previous dllimport ignored
                      .
                      .
                      

                      and errors

                      QTProjects\build-Alpha2-Desktop_Qt_5_7_0_MinGW_32bit-Debug/debug/moc_qled.cpp:151: undefined reference to `_imp___ZN4QLed10setOnColorENS_8ledColorE
                      QTProjects\build-Alpha2-Desktop_Qt_5_7_0_MinGW_32bit-Debug/debug/moc_qled.cpp:153: undefined reference to `_imp___ZN4QLed8setShapeENS_8ledShapeE
                      .
                      .
                      

                      tried to add qledplugin.dll as lib in the .pro file too without success.

                      Have you any suggestion ? :)
                      Thanks again for the attention and time

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

                        Yes. If you remove the QDESIGNER_WIDGET_EXPORT
                        from the qled.h it will link and run
                        as in

                        class /*QDESIGNER_WIDGET_EXPORT*/ QLed : public QWidget {
                        

                        You also need the qres in PRI file
                        qled.pri

                        QT += svg
                        INCLUDEPATH += $$PWD
                        HEADERS += $$PWD/qled.h
                        SOURCES += $$PWD/qled.cpp
                        
                        RESOURCES += $$PWD/qled.qrc
                        

                        Note that this is slightly hack-ish as you need QDESIGNER_WIDGET_EXPORT when compiling as plugin.
                        But not when using it via .PRI file.

                        B 1 Reply Last reply
                        3
                        • mrjjM mrjj

                          Yes. If you remove the QDESIGNER_WIDGET_EXPORT
                          from the qled.h it will link and run
                          as in

                          class /*QDESIGNER_WIDGET_EXPORT*/ QLed : public QWidget {
                          

                          You also need the qres in PRI file
                          qled.pri

                          QT += svg
                          INCLUDEPATH += $$PWD
                          HEADERS += $$PWD/qled.h
                          SOURCES += $$PWD/qled.cpp
                          
                          RESOURCES += $$PWD/qled.qrc
                          

                          Note that this is slightly hack-ish as you need QDESIGNER_WIDGET_EXPORT when compiling as plugin.
                          But not when using it via .PRI file.

                          B Offline
                          B Offline
                          Bruschetta
                          wrote on last edited by
                          #19

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

                          mrjjM 1 Reply Last reply
                          2
                          • 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

                                          • Login

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