Project

General

Profile

Looking for a parent for a WTabWidget tab

Added by ViNotion BV over 11 years ago

Hi there,

I'm developing a GUI application that features a WTabWidget. The widget that forms the content of a tab does not inherit the style of the parent page (and the WTabWidget itself), as I'm not able to find a suitable parent for the widget.

The condensed code looks something like (this all happens within a WContainerWidget):

  std::vector<std::string> names;
  Wt::WTabWidget *tabs = new Wt::WTabWidget(this);

  // Fill up names vector..

  // Create a tab for each name
  for (auto iter: names)
  {
    tabs->addTab(new Wt::WDateEdit(), iter);
  }

The style of the WDateEdit field does not match the style of the tab widget (and its parents). I take it, this is due to the fact that the WDateEdit widget does not inherit this as it has no parent class. For some reason, there's no way I can get the same look for the WDateEdit as displayed here: http://www.webtoolkit.eu/widgets/forms/date-entry. I use the `polished' theme for the rest of my application.

If (as usual) I choose `this' as the parent a 'reparenting widget' warning is shown, like so:

    tabs->addTab(new Wt::WDateEdit(this), iter);

Can someone suggest me the proper method for parenting the tab contents widget here? Or, if this is not the reason of the error; can someone explain me how to get a WDateEdit with a button that looks like the one in the widget gallery.

Thanks in advance,

Kris


Replies (5)

RE: Looking for a parent for a WTabWidget tab - Added by ViNotion BV over 11 years ago

As a little side-step, here's how the WDateEdit widgets look (see attachment, using the example code from the widget gallery).

The calendar popup-only appears half of the time and there is no button next to the text field.

RE: Looking for a parent for a WTabWidget tab - Added by Koen Deforche over 11 years ago

Hey,

Using the polished theme, the date edit should look like this: http://www.webtoolkit.eu/widgets/forms/date-entry?theme=polished

I don't know why you do not have the icon, you should see a 404 request for the icon which is missing? Note that the icon is inside the line edit, it's being applied as part of a background image. Perhaps you override this in your CSS rules?

When adding a tab to a tab widget, the tab widget will take ownership of the tab. So there's no need to parent it yourself (and the tab widget will reparent if needed).

Usually, a tab is a container which contains more than one widget though?

Regards,

koen

RE: Looking for a parent for a WTabWidget tab - Added by ViNotion BV over 11 years ago

Hi Koen,

Thanks for your reply. The tab widget is a container widget containing other widgets yes, but I just used the Wt::WText as an example here. The tabwidget is ok then.

Our CSS is empty, so we don't override anything. Also, there is no 404 in the server output.

It's quite interesting to see, that when one clicks on the place the icon should be, the calendar date picker appears. I just wasn't aware there should be an icon there :-)

A close inspection of the HTML/CSS for the input element that is the Wt::WDateEdit field, no icon or image can be found. I can see from the online widget gallery that the icon is loaded in 'background-image: url('../../calendar_edit.png');' in the 'Wt-dateedit' CSS class. This class is not existent in our release of Wt (it only exists in the bootstrap theme). We are using Wt-3.3.0.

Actually, when comparing our release to Wt-3.3.1, it seems the polished/wt.css file is updated and works as it should.

We were wondering whether the default theme style for your online widget gallery (which looks really good) is available as well?

Best regards,

Kris

P.S. It seems that the bootstrap theme is only partially functional. See for example: http://www.webtoolkit.eu/widgets/navigation/tab-widget?theme=bootstrap

RE: Looking for a parent for a WTabWidget tab - Added by Koen Deforche over 11 years ago

Hey Kris,

Perhaps indeed in 3.3.0 we didn't yet upgrade the CSS themes to the new functionality that was made in response to bootstrap.

To use the bootstrap theme, you need to use setTheme(new WBootstrapTheme()). It's included in Wt.

Regards,

koen

RE: Looking for a parent for a WTabWidget tab - Added by ViNotion BV over 11 years ago

Hi Koen,

Thanks for the reply. I changed the way the theme is set, I didn't realize the difference in theme usage.

We've moved to Wt-3.3.1 and now everything looks fine (aside from some alignment/size-related quirks). Thanks!

Best regards,

Kris

    (1-5/5)