I am trying to load all my forms from the Ui files with QUiLoader. I ran into the problem with QSystemTrayIcon. For some reason QFormBuilder fails to load my form.
My Ui file:
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SystemTrayIcon</class>
<widget class="QSystemTrayIcon" name="SystemTrayIcon">
<property name="icon">
<iconset>:/icons/tray_icon.png</iconset>
</property>
</widget>
<resources/>
<connections/>
</ui>
And I load it with the following code:
tray_icon tray_icon_factory::build()
{
QUiLoader loader;
QFile file(":/forms/tray_icon.ui");
file.open(QFile::ReadOnly);
QWidget *widget = loader.load(&file);
file.close();
tray_icon the_tray_icon(widget);
return the_tray_icon;
}
When I compile and run my application I get the following error:
"QFormBuilder was unable to create a widget of the class 'QSystemTrayIcon'."
What I am doing wrong and how I can fix this problem?
QSystemTrayIcon
is not a widget, so you can't create it from an ui file.