budda
16th April 2010, 07:31
I can't for the life of me, figure out how to get a tutorial page's code to work as a child widget inside my MainWindow
I have it working with the ui form and a QTextedit. But I need the QPainter ability in the text area, so I read here that the QPlainTextedit is what you use... only problem is that I can't get the header and cpp of this class to be a widget in my main...
http://doc.trolltech.com/4.5/widgets-codeeditor.html this is the example I am using. I'm shooting for this class or something close to it as a widget... I don't know if I'm just not giving it a setGeometry call or something.... Do I have to initialize it in the main.cpp? This CodeEditor class is what I need sorta for a Hex View Inspector code I have going... I guess I'm just not wrapping my head around the stucture of the *parent Widget and child Widget and how you add them correctly....
I named my class HexView (it is a PlainTextedit) and I'm using somthing damn close to the CodeEditor class. I tried to initalize an instance of it in a method class in MainWindow with the code of hexView = new HexView(QWidget *parent); but this isn't working.... and I tried
void hexTxt(QWidget &hexView)
{
//HexView widget2;
hexView.setGeometry(10,190,551,381);
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.setWindowTitle("Hex Inspector");
w.show();
hexTxt(w);
return a.exec();
}
in the main.cpp and can't get it to establish the freaking widget.... any feed back would be greatly appreciated.....
oh ya using latest Qt version with C++
I have it working with the ui form and a QTextedit. But I need the QPainter ability in the text area, so I read here that the QPlainTextedit is what you use... only problem is that I can't get the header and cpp of this class to be a widget in my main...
http://doc.trolltech.com/4.5/widgets-codeeditor.html this is the example I am using. I'm shooting for this class or something close to it as a widget... I don't know if I'm just not giving it a setGeometry call or something.... Do I have to initialize it in the main.cpp? This CodeEditor class is what I need sorta for a Hex View Inspector code I have going... I guess I'm just not wrapping my head around the stucture of the *parent Widget and child Widget and how you add them correctly....
I named my class HexView (it is a PlainTextedit) and I'm using somthing damn close to the CodeEditor class. I tried to initalize an instance of it in a method class in MainWindow with the code of hexView = new HexView(QWidget *parent); but this isn't working.... and I tried
void hexTxt(QWidget &hexView)
{
//HexView widget2;
hexView.setGeometry(10,190,551,381);
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.setWindowTitle("Hex Inspector");
w.show();
hexTxt(w);
return a.exec();
}
in the main.cpp and can't get it to establish the freaking widget.... any feed back would be greatly appreciated.....
oh ya using latest Qt version with C++