Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Designer plugin widget: how to achieve different look in preview than in design view?
Forum Updated to NodeBB v4.3 + New Features

Designer plugin widget: how to achieve different look in preview than in design view?

Scheduled Pinned Locked Moved Qt Creator and other tools
2 Posts 1 Posters 1.8k 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.
  • A Offline
    A Offline
    andre
    wrote on last edited by
    #1

    I am building some Qt Designer plugins for some widgets that I have created. One widget is basically acting like a spacer, so it should be non-visible at runtime. However, it would be nice if I could make it draw something for display at design time, to make it easier to handle. Basically, it should look a bit like the spacers do in design view. The actual drawing isn't that hard, but I can not find a way to distinguish if my widget is created for use design view or for use in preview. It seems in both cases, the plugins' createWidget() method is called, and there are no parameters there I can use for this it seems. Any suggestions, tips or tricks to get around this?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      Hmmm... OK, one solution (bit of a hack, but ok) is to use this implementation of the createWidget() method:

      @
      QWidget *CheckBoxSpacerWidgetPlugin::createWidget(QWidget parent)
      {
      MyWidget
      resultWidget = new MyWidget(parent);

      QWidget* pw = parent;
      
      while (pw) {
          qDebug() << "parent class:" << pw->metaObject()->className() << pw->inherits("QDesignerWidget");
          if (pw->inherits("QDesignerWidget") ) { //this one seems to be only used in Design mode--
              //the m_inDesignerModeFlag is private in the widget, but the plugin is a friend class of the widget
              resultWidget->m_inDesignerModeFlag = true; 
              break;
          }
          pw = pw->parentWidget();
      }
      
      return resultWidget;
      

      }
      @

      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