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] Custom Layout plugin for Qt Designer does not work
Forum Updated to NodeBB v4.3 + New Features

[Solved] Custom Layout plugin for Qt Designer does not work

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

    Hello everyone!

    I am trying to create a custom plugin for QtDesigner, but I fail so far.
    I wanted a layout that, when it's resized, it preserves the aspect ratio of its attached children. Using an online tutorial of how to make custom layouts I finaly did it and it works. But now I want to be able to use this custom layout from inside the QtDesigner. So, I created a new MSVC2008 project using the "Qt4 Designer Plugin" template. This template generates a lot of code. As you already know it creates a plugin class that inherits from QObject and QDesignerCustomWidgetInterface classes. In this code I changed only 2 functions:

    • I changed the "isContainer()" function to return true.(but I also tried it with false)
    • And I changed the createWidget() function. Here I had an other problem. This function returns a QWidget* while I want to create a CustomLayout* (which inherits QLayout). The only solution I could think of was to create a QWidget object and use "setLayout()" function to set on it my CustomLayout class object. And then return the QWidget object. Is this the right solution? here is my code:
      @
      QWidget CustomLayoutPlugin::createWidget(QWidget parent)
      {
      CustomLayout
      layout = new CustomLayout(parent);
      QWidget
      widget = new QWidget(parent);
      widget->setLayout(layout);
      return widget;
      }
      @
      After those 2 changes I compiled it, I took the debug and release lib and dlls files and I placed them under the "<QtFolder>\plugins\designer" path. So far so good. Now my CustomLayout appears in the toolbox of the QtDesigner but I have the following problems:
    • When I click on the Layout to drag it on the form I get this message: "A class name mismatch occurred when creating a widget using the custom widget factory registered for widgets of class CustomLayout. It returned a widget of class QWidget"
    • Regardless the message above, I can place the CustomLayout on the form but it does not seem to work. The widgets I attach to it do not move/resize/stretch at all. Like there is no Layout. Btw: The Class name at the Object inspector is QWidget and there is no CustomLayout attached to it.

    What am I doing wrong? Thank you for your time.

    Cheers!

    1 Reply Last reply
    0
    • S Offline
      S Offline
      sigrid
      wrote on last edited by
      #2

      Designer currently does not support using custom layout plugins. Adding support for it is listed as a suggestion for Qt 5.0 "here":http://bugreports.qt.nokia.com/browse/QTBUG-3109

      Feel free to use the link above to vote for the suggestion.

      1 Reply Last reply
      0
      • B Offline
        B Offline
        Bekos
        wrote on last edited by
        #3

        Thanks for letting me know that this is not possible in the current version!

        Cheers!

        [quote author="sigrid" date="1306498691"]Designer currently does not support using custom layout plugins. Adding support for it is listed as a suggestion for Qt 5.0 "here":http://bugreports.qt.nokia.com/browse/QTBUG-3109

        Feel free to use the link above to vote for the suggestion.[/quote]

        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