Gtkd how to add double value to liststore
    Erdem via Digitalmars-d-learn 
    digitalmars-d-learn at puremagic.com
       
    Sat Jan 14 11:47:01 PST 2017
    
    
  
I would like to pass some double value to ListStore's constructor 
but it doesn't allows me to do.
import gtk.Main;
import gtk.MainWindow;
import gtk.Box;
import gtk.ListStore;
import gtk.TreeView;
import gtk.TreeViewColumn;
import gtk.TreeIter;
import gtk.CellRendererText;
class MyWindow: MainWindow
{
     Box mainBox;
     this()
     {
         super("Tree view exercise");
         setBorderWidth(10);
         mainBox = new Box(Orientation.HORIZONTAL, 0);
         add(mainBox);
         showAll();
     }
}
class InfoModel: ListStore /* model */
{
     this()
     {
         super([GType.STRING, GType.DOUBLE]);
     }
     void addGoods(string name, double price)
     {
         TreeIter iterator = createIter();
         setValue(iterator, 0, name);
         setValue(iterator, 1, price);
     }
}
class DisplayModel: TreeView /* view */
{
     TreeViewColumn articleColumn;
     TreeViewColumn priceColumn;
     this (ListStore model)
     {
         articleColumn = new TreeViewColumn("Article", new 
CellRendererText(), "text", 0);
     }
}
void main(string[] args)
{
     Main.init(args);
     new MyWindow();
     Main.run();
}
When I try to compile this program it gives this error message:
Error: none of the overloads of 'setValue' are callable using 
argument types (TreeIter, int, double), candidates are:
import/gtk/ListStore.d(273):        
gtk.ListStore.ListStore.setValue(TreeIter iter, int column, 
string value)
import/gtk/ListStore.d(281):        
gtk.ListStore.ListStore.setValue(TreeIter iter, int column, int 
value)
import/gtk/ListStore.d(569):        
gtk.ListStore.ListStore.setValue(TreeIter iter, int column, Value 
value)
Also is it possible to round this double to 2 decimal places when 
presenting data with GtkTreeView.
    
    
More information about the Digitalmars-d-learn
mailing list