first wxdataviewmodel

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
guzzi_jones
Experienced Solver
Experienced Solver
Posts: 81
Joined: Sun Dec 08, 2013 3:50 am

first wxdataviewmodel

Post by guzzi_jones » Sat Dec 21, 2013 1:46 am

I am attempting to write my first wxdataviewmodel.
I am using codeblocks 10.5 with wxwidgets 2.8.

I have a file created with this code:

//MYLTYPE
#ifndef MYLTYPE_H
#define MYLTYPE_H
#include <wx/dataview.h>

class myltype: public wxDataViewModel
{


}
#endif

the error i am getting is:
/home/aj/bdn/myltype.h|7|error: expected class-name before ‘{’ token|
/usr/include/stdlib.h|35|error: expected unqualified-id before string constant|
/usr/include/c++/4.6/exception|37|error: expected declaration before end of line|
||=== Build finished: 3 errors, 0 warnings ===|

guzzi_jones
Experienced Solver
Experienced Solver
Posts: 81
Joined: Sun Dec 08, 2013 3:50 am

Re: first wxdataviewmodel

Post by guzzi_jones » Sat Dec 21, 2013 1:54 am

no clue, but i created the class using File | New Class and it compiles now.

guzzi_jones
Experienced Solver
Experienced Solver
Posts: 81
Joined: Sun Dec 08, 2013 3:50 am

Re: first wxdataviewmodel

Post by guzzi_jones » Sat Dec 21, 2013 2:01 am

hmm as soon as i add the inheritance : wxDataViewModel
i get the error.

User avatar
doublemax
Moderator
Moderator
Posts: 15264
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: first wxdataviewmodel

Post by doublemax » Sat Dec 21, 2013 11:26 am

Can you build the "dataview" sample that comes with wxWIdgets?
Check the value of wxUSE_DATAVIEWCTRL. Maybe the control is disabled in your build.
Use the source, Luke!

guzzi_jones
Experienced Solver
Experienced Solver
Posts: 81
Joined: Sun Dec 08, 2013 3:50 am

Re: first wxdataviewmodel

Post by guzzi_jones » Sat Dec 21, 2013 1:21 pm

no i cannot. I actually get the same error

guzzi_jones
Experienced Solver
Experienced Solver
Posts: 81
Joined: Sun Dec 08, 2013 3:50 am

Re: first wxdataviewmodel

Post by guzzi_jones » Sat Dec 21, 2013 2:06 pm

g++ -c -o dataview_dataview.o -I. `wx-config --cxxflags` -MTdataview_dataview.o -MF`echo dataview_dataview.o | sed -e 's,\.o$,.d,'` -MD -MP dataview.cpp
dataview.cpp:42:1: error: expected class-name before ‘{’ token
2 dataview.cpp:140:1: error: expected class-name before ‘{’ token
3 dataview.cpp:169:20: error: ‘wxDataViewListModel’ has not been declared
4 dataview.cpp: In constructor ‘MyCustomRenderer::MyCustomRenderer()’:
5 dataview.cpp:143:9: error: class ‘MyCustomRenderer’ does not have any field named ‘wxDataViewCustomRenderer’
6 dataview.cpp:143:50: error: ‘wxDATAVIEW_CELL_ACTIVATABLE’ was not declared in this scope
7 dataview.cpp: At global scope:
.....

User avatar
doublemax
Moderator
Moderator
Posts: 15264
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: first wxdataviewmodel

Post by doublemax » Sat Dec 21, 2013 2:41 pm

This probably means that dataviewcontrol is not enabled in your wxWidgets libraries. (Check the value of wxUSE_DATAVIEWCTRL). Did you build them yourself?
Use the source, Luke!

guzzi_jones
Experienced Solver
Experienced Solver
Posts: 81
Joined: Sun Dec 08, 2013 3:50 am

Re: first wxdataviewmodel

Post by guzzi_jones » Sat Dec 21, 2013 3:00 pm

I am a newb. how do i test that variable.

As a side note i have noticed that if I put
#include "wx/generic/dataview.h"

in my header area i am able to get past that error, but stop at another error trying to complile the sample dataview.h.

Is this a setting in wx that i need to change so it grabs ALL the generic headers?

I did try to install wxwidgets 3.0, but then i deleted it and just reinstalled 2.8 through synaptic.

User avatar
doublemax
Moderator
Moderator
Posts: 15264
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: first wxdataviewmodel

Post by doublemax » Sat Dec 21, 2013 4:12 pm

Put this at the beginning of your code and compile. If wxUSE_DATAVIEWCTRL is not defined, you should get the error message.

Code: Select all

#if !wxUSE_DATAVIEWCTRL
  #error wxDataViewCtrl not available
#endif
I'd suggest to grab the wx3.0.0 sources and build the libraries yourself.
Use the source, Luke!

guzzi_jones
Experienced Solver
Experienced Solver
Posts: 81
Joined: Sun Dec 08, 2013 3:50 am

Re: first wxdataviewmodel

Post by guzzi_jones » Sun Dec 22, 2013 1:10 am

i had to manually eliminate the remnants of the 3.0 I installed.
the uninstall did not totally get rid of it.

guzzi_jones
Experienced Solver
Experienced Solver
Posts: 81
Joined: Sun Dec 08, 2013 3:50 am

Re: first wxdataviewmodel

Post by guzzi_jones » Tue Dec 24, 2013 3:12 am

ok i have tried to download the gtk version of wxwidgets3.0.0.
I am running ubuntu 12.04 lte
I attempated to build it myself and install it according to directions in the doc folder.
I still could not compile dataview.cpp
here is the output of make

g++ -c -o dataview_dataview.o -I. `wx-config --cxxflags` -MTdataview_dataview.o -MF`echo dataview_dataview.o | sed -e 's,\.o$,.d,'` -MD -MP dataview.cpp
/bin/sh: 1: wx-config: not found
dataview.cpp:12:4: error: #error wxDataViewCtrl not available
dataview.cpp:15:23: fatal error: wx/wxprec.h: No such file or directory
compilation terminated.
make: *** [dataview_dataview.o] Error 1

guzzi_jones
Experienced Solver
Experienced Solver
Posts: 81
Joined: Sun Dec 08, 2013 3:50 am

Re: first wxdataviewmodel

Post by guzzi_jones » Tue Dec 24, 2013 4:38 am

Is there some place that i can check that this is enabled in my download of wxWidgets3.0.0?
I see this on an old post from 08

http://ubuntuforums.org/archive/index.php/t-937810.html
optional:
--enable-dataviewctrl use wxDataViewCtrl class

User avatar
doublemax
Moderator
Moderator
Posts: 15264
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: first wxdataviewmodel

Post by doublemax » Tue Dec 24, 2013 10:24 am

wxDataViewCtrl should be enabled by default in wx 3.0.

Try to stick with the samples and building using the makefile.

After you build the wx libraries, there is a generated setup.h where you could also check the value of wxUSE_DATAVIEWCTRL. Let's assume you created a directory "build-debug" in the wxWidgets source directory. Then the setup.h would be in <wxdir>/build-debug/lib/wx/include/<build-name>/wx/setup.h
Use the source, Luke!

Post Reply