Paip. C language gtk Development Environment CodeBlocks/QT build Best Practices

Source: Internet
Author: User

Paip. C language gtk Development Environment CodeBlocks/QT build Best Practices




Author Attilax, EMAIL: 1466519819@qq.com
Source: attilax Column
Address: http://blog.csdn.net/attilax




1. Prepare the tool:
//////////////////////////////
Ide: CodeBlocks 12.11 (28 M)... of course, it can also use powerful QT
Interface Designer: glade-3-14-2-installer.exe




2. Create a New gtk Project
///////////////////////////////
Select the gtk sdk path in the middle, D: \ gtk + bundle_2.24.10-20120208_win32del




3. Create an interface using glade-3-14-2
/////////////////////////////////////
Save the gtkbuilder format when saving... and the old libglade format is also available ..
Since the gtk version was upgraded to 2.12, it contains the function of GtkBuilder. GtkBuilder, which is the same as libglade, used to load the glade file,




4. Add source code
//////////////////////////////////
# Include <stdlib. h>
# Include <gtk/gtk. h>
# Include <glade. h>
# Include <glib. h>


Int main (int argc, char * argv [])
{
Gtk_init (& argc, & argv );


GtkBuilder * pBuilder = NULL;
GtkWidget * pMainWindow = NULL;


PBuilder = gtk_builder_new ();
GError * err = NULL;
If (0 = gtk_builder_add_from_file (pBuilder, "c:/haloc9.gtkfmt", & err ))
{
/* Print out the error. You can use GLib's message logging */
Fprintf (stderr, "Error adding build from file. Error: % s \ n", err-> message );
/* Your error handling code goes here */
}




PMainWindow = GTK_WIDGET (gtk_builder_get_object (pBuilder, "window1 "));
If (NULL = pMainWindow)
{
/* Print out the error. You can use GLib's message logging */
Fprintf (stderr, "Unable to file object with id \" window1 \ "\ n ");
/* Your error handling code goes here */
}




Gtk_builder_connect_signals (pBuilder, NULL );
Printf ("aa ");


G_object_unref (G_OBJECT (pBuilder ));
Gtk_widget_show (pMainWindow );




/* Enter the main loop */
Gtk_main ();
Return 0;
}




/* Since the gtk version is upgraded to 2.12, it contains the GtkBuilde
GladeXML * xml = NULL;
GtkWidget * pMainWindow = NULL;
Xml = glade_xml_new ("d:/halo. glade", "app", NULL );
PMainWindow = glade_xml_get_widget (xml, "window1"); // you can use the gtk code to operate the widget after obtaining the control pointer.
*/
/* Create a vertical box with buttons


Unknown type name


Button = gtk_button_new_from_stock (GTK_STOCK_DIALOG_INFO );
G_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (helloWorld), (gpointer) win );


*/




/**/
/*
GtkWidget * window = NULL;
Window = gtk_window_new (GTK_WINDOW_TOPLEVEL );
Gtk_window_set_title (GTK_WINDOW (window), "icon ");
Gtk_window_set_default_size (GTK_WINDOW (window), 230,150 );
Gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER );
// Gtk_window_set_icon (GTK_WINDOW (window), create_pixbuf ("web.png "));
Gtk_widget_show (window );
// Gtk_widget_show_all (pMainWindow );
*/












5. CodeBlocks set the compiler and debugger
////////////////////////////////////////
Setables> complier setables> toolchain executables (tab)> D: \ Qt \ Qt5.1.1 \ Tools \ mingw48_32
Program files (tab)> c compiler: gcc.exe and liker: gw.0000.exe
Setier> complier setgger> debugger> D: \ Qt \ Qt5.1.1 \ Tools \ mingw48_32 \ bin \ gdb.exe




6. Run OK.
///////////////////////






Add include and *. h header files to CodeBlocks
//////////////////////////////////////// //////
Setction> complier setction> searching drirection (tabs)> add a dir ..


D: \ cworkspace \ AtiGtk \ main. c | 10 | error: unknown type name 'gladexml' |




Reference
Gtk graphic interface development steps (gtk code and glade xml graphic design separation)-clydezhou column-blog channel-CSDN.NET.htm
The first GTK + program-Neo E. Cai-blog. htm
Software similar to GtkBuilder-GTK interface development tool-Open Source China Community Zone .htm
C-Gtk-Critical gtk_widget_show assertion GTK_IS_WIDGET (WIDGET)-Stack Overflow
GTK + and Glade3 GUI Programming Tutorial-Part 1.htm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.