Whenever I use a GtkBox to hold a WebKitWebView, it does not display on screen. However when directly appending the WebKitWebView as the child of the window, it does.
This works:
GtkWidget *webviewWidget = webkit_web_view_new();
WebKitWebView *webview = WEBKIT_WEB_VIEW(webviewWidget);
webkit_web_view_load_uri(webview, "https://www.example.com");
gtk_window_set_child(window, webviewWidget);
However, this does not (appear to):
GtkWidget *horizontalBoxWidget = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
GtkBox *horizontalBox = GTK_BOX(horizontalBoxWidget);
GtkWidget *webviewWidget = webkit_web_view_new();
WebKitWebView *webview = WEBKIT_WEB_VIEW(webviewWidget);
gtk_box_append(horizontalBox, webviewWidget);
webkit_web_view_load_uri(webview, "https://www.example.com");
gtk_window_set_child(window, horizontalBoxWidget);
I was looking here for documentation: https://docs.gtk.org/gtk4/#classes.
(Was intending to add another element to the box later)
gtk_window_present(window);at the end.gtk_widget_set_size_request(horizontalBoxWidget, 400, 400);or some other method. The widget doesn't automatically expand.