PDA

View Full Version : using arthurwidgets.h and arthurwidgets.cpp?



nikita
19th August 2006, 04:06
hey,
i've looked everywhere to see how to write a main window, dialog, or just label ->show the widget style used in the arthur demos apps in qt4. so far i've read the docs and it seems that it would be a custom style issue, however no dice so far. i need info as to whether i call arthurwidgets.cpp as a style or whatever... any assistance or kick in the right direction would be appreciated. thanks in advanced

wysota
19th August 2006, 11:37
Look at the demos using those widgets. In their main() there is something like this:


QStyle *arthurStyle = new ArthurStyle();
compWidget.setStyle(arthurStyle);

QList<QWidget *> widgets = qFindChildren<QWidget *>(&compWidget);
foreach (QWidget *w, widgets)
w->setStyle(arthurStyle);

The first line does most of the magic (loads the style). Then this code sets the style to some widgets in the application. If you want to set the style for all widgets in an application, you can use QApplication::setStyle instead.

The style is defined in demos/shared/arthurstyle.{h,cpp} in your QTDIR.

nikita
21st August 2006, 00:52
thanks,
however i got this error:

g++ -pthread -Wl,-rpath,/usr/local/Trolltech/Qt-4.1.4/lib -o experiment main.o arthurwidgets.o arthurstyle.o moc_arthurwidgets.o -L/usr/local/lib -L/usr/local/Trolltech/Qt-4.1.4/lib -lQtGui_debug -L/qt-x11-opensource-src-4.1.4/lib -L/usr/local/lib -L/usr/X11R6/lib -lpng -lSM -lICE -lXi -lXrender -lXrandr -lXcursor -lXinerama -lfreetype -lfontconfig -lXext -lX11 -lQtCore_debug -lz -lm
arthurstyle.o(.text+0x29b): In function `ArthurStyle::ArthurStyle()':
../shared/arthurstyle.cpp:53: undefined reference to `qInitResources_shared()'
arthurstyle.o(.text+0x2e7): In function `ArthurStyle::ArthurStyle()':
../shared/arthurstyle.cpp:53: undefined reference to `qInitResources_shared()'
*** Error code 1

as you can see it begins during linking and the corresponding line in arthurstyle.cpp:

ArthurStyle::ArthurStyle()
: QWindowsStyle()
{
Q_INIT_RESOURCE(shared); //culprit on line 53
}

i haven't a clue as to what this is referencing ... i'll start looking through the headers after
i take a break. could be the .pro file is missing dependency? i'll write again in a little while.

nikita
21st August 2006, 01:46
okay qmake macro expansion, didn't know you could do that from a source file... i got it to build and i now see that i should take a good look at the .pri .pro and .qrc in the shared folder. i'm actually building my first real app so i really appreciate all the help. thanks again. :D