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. Custom Widget Problem
Forum Updated to NodeBB v4.3 + New Features

Custom Widget Problem

Scheduled Pinned Locked Moved General and Desktop
7 Posts 2 Posters 3.7k 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.
  • R Offline
    R Offline
    rdfrahm
    wrote on last edited by
    #1

    I've created a (container) custom widget using QT Creator -> New File or Project -> Other -> Qt Custom Designer Widget. After building, I copy the .so file (I'm using Ubuntu) to /usr/lib/qt4/plugins/designer and the plugin header file to both /usr/include and usr/include/qt4. Everything goes perfectly in designer...I can find my widget in the widgets panel and add it to my form. But when I try to build I get this error:

    collect2: ld returned 1 exit status

    The Compile output shows this:

    mainwindow.cpp.text._ZN13Ui_MainWindow7setupUiEP11QMainWindow[Ui_MainWindow::setupUi(QMainWindow*)]+0x1382): undefined reference to `RDF_TempProbe_Widget::RDF_TempProbe_Widget(QWidget*)'

    RDF_TempProbe_Widget is my custom widget. I've seen many threads discussing this problem but thus far have not been able to resolve it. Any ideas?

    Thanks,
    Rich

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dbzhang800
      wrote on last edited by
      #2

      you need to add yourcustomwidget.cpp to you project's file

      @
      HEADERS += yourcustomwidget.h
      SOURCES += yourcustomwidget.cpp
      @

      or

      @
      LIBS += yourcustomwidget.so # this is not a plugin!
      @

      1 Reply Last reply
      0
      • R Offline
        R Offline
        rdfrahm
        wrote on last edited by
        #3

        Thanks for the input Robot Herder! Adding my widget's header and source files to the project did indeed work, but shouldn't Qt handle everything once I've successfully built the plugin and the widget? It seems like it should work just like any stock widget and I should be able to just plop it onto my form and everything is taken care of. That's the way it's worked in other environments I've used (primarily Delphi).

        Thanks,
        Rich

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dbzhang800
          wrote on last edited by
          #4

          In fact, that plugin isn't used in the build process. It's used by the designer only which assistant you to generate the .ui file. and in most cases, you doesn't need to create a plugin.

          1 Reply Last reply
          0
          • R Offline
            R Offline
            rdfrahm
            wrote on last edited by
            #5

            But if I want to see it in Designer so I can place it where I want it, I need a plugin, right? And it seems like I should be able to set it's properties in Designer just like I would any other widget.

            Thanks for your tutoring...I really appreciate it!

            Rich

            1 Reply Last reply
            0
            • D Offline
              D Offline
              dbzhang800
              wrote on last edited by
              #6

              [quote author="rdfrahm" date="1335837483"]But if I want to see it in Designer so I can place it where I want it, I need a plugin, right? And it seems like I should be able to set it's properties in Designer just like I would any other widget.
              Rich[/quote]

              Yes, you are right. If you use this control frequently, create a plugin will give you much benefit.

              ;-)

              But you can do nearly the same thing even without a plugin by Promoting Widgets and Dynamic Properties.

              http://qt-project.org/doc/qt-4.8/designer-using-custom-widgets.html
              http://qt-project.org/doc/qt-4.8/designer-widget-mode.html

              1 Reply Last reply
              0
              • R Offline
                R Offline
                rdfrahm
                wrote on last edited by
                #7

                Thanks Robot Herder...I'll do (more) reading. I really appreciate your help!

                Rich

                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