1

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)

2
  • @3CEZVQ That doesn't seem to be a method, maybe it was previously...? I was using gtk_window_present(window); at the end. Commented Jul 29 at 2:37
  • Didn't realize because I didn't need to beforehand, but a size must explicitly be set via gtk_widget_set_size_request(horizontalBoxWidget, 400, 400); or some other method. The widget doesn't automatically expand. Commented Jul 29 at 17:20

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.