You are not logged in.

Search results

Search results 1-20 of 27.

Friday, July 15th 2005, 3:04pm

Author: spellcaster

doubleclick on QMainWindow

If you want to react to events, you'll have to derive from the class. I was expecting signals for the events as well. But if you need / want them, you'll have to derive a class and emit them yourself, sorry. But you'll get used to the Qt way pretty soon. Customizing a widget is normally done with subclassing - which isn't actually a bad design decision

Thursday, July 14th 2005, 11:59pm

Author: spellcaster

Simpel DB app that uses only one connection

See my first examples on setting a static class variable. It has to be done outside the class definition. Simply uncommenting line 56 of your cpp should work

Thursday, July 14th 2005, 8:16pm

Author: spellcaster

Simpel DB app that uses only one connection

If you don't want to use a pointer: don't Simply check whether or not you're connected and connect if needed. EDIT: In your case, you could also simply create the connection in the constructor (since the values seem to be constant)

Thursday, July 14th 2005, 4:09pm

Author: spellcaster

Simpel DB app that uses only one connection

No problem, but remember this is very rough. Your connect method could for example emit a signal if it's not already connected to a db. You could connect that signal to a slot in your application that would query the required information from the user and connects.

Thursday, July 14th 2005, 3:43pm

Author: spellcaster

Simpel DB app that uses only one connection

If this is a "real" DB application you'll need some extra data. In that case you could do something like this: Source code 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 class ConnectionSource { private: QSqlDatabase *db; static ConnectionSource instance; ConnectionSource() { } public: static ConnectionSource * getInstance() { if (instance == NULL) { instance = new ConnectionSource(); } return instance; } bool connect(QString &datasource, QString &user, QString ...

Thursday, July 14th 2005, 2:44pm

Author: spellcaster

Simpel DB app that uses only one connection

The simple solution would be a global variable. The not so simple but more OO solution would be something like this: Source code 1 2 3 4 5 6 7 8 9 10 11 12 13 14 class ConnectionSource { private: static QSqlDatabase *db; public: static QSqlDatabase* getDB() { if (db == NULL) { // setup db } return db; } }; ConnectionSource ::db = NULL;

Thursday, July 14th 2005, 2:02pm

Author: spellcaster

Program keeps running...

Well, what does your Dialog do? The code you posted should work if your dialog behaves nicely.

Thursday, July 14th 2005, 12:53pm

Author: spellcaster

i don't understand ..[what for is the included moc line]

Here is a short quotation from 'Qt reference documentation' : Quoted The moc reads a class declaration and produces a C++ source file containing the names of all signals and slots for that class (and a little more). This C++ source file the moc outputs must be compiled and linked with the implementation of the class (or it can be #included into the source file). In other words - the moc file is used to give you all that nice extras you love Qt for

Thursday, July 14th 2005, 10:52am

Author: spellcaster

List resizing and Grid

I've a splitter that contains a ScrollArea with listWidget. The ListWidget is set to iconview with a 120x120 grid layout. I called ScrollArea resizeWidget(true) for the ScrollArea, and whenever I change the splitter position the listWidget resizes - but the grid doesn't change. Let's say the grid was 2x200 and I double with width, I'd expect the grid to change to 4x100. How can I force this?

Wednesday, July 13th 2005, 2:19pm

Author: spellcaster

Images on QCanvasRectangle

Have you checked whether or not the pixmap is a null pixmap? A simple way would be: Source code 1 2 3 4 5 6 QPixmap fooPixmap = QPixmap("../icons/stp.xpm"); if (fooPixmap.isNull()) { // debug output, default pixmap, whatever } else { painter.drawPixmap ( 0, 0, fooPixmap, 0, 0, -1, -1 ); } Also note that the working directory of your app (the one it considers ".") doesn't have to be the directory the exectuable is in. How do you start your executable?

Wednesday, July 13th 2005, 12:28pm

Author: spellcaster

Images on QCanvasRectangle

Well, you could use a simple manager class. A very simple manager could work like this: Pseudocode: Source code 1 2 3 4 5 6 7 8 9 10 11 QImage& Manager::getResource( filename) { // the "internal cache" could be a hashmap if ( internal cache contains key filename ) { return cached copy } else { load image store image in cache return loaded image } } If you need to frequently clear groups of images (say you want to code an image browser and only want to cache n directories at any time), you can sp...

Wednesday, July 13th 2005, 11:56am

Author: spellcaster

Images on QCanvasRectangle

Some small comments: If you do like this, your pixmap will be loaded every time the widget is rendered. This isn't very efficient. Also, since you're creating a tmp. var, you'll have problems checking the actual result of the call - my guess is that the icon isn't found.

Wednesday, July 13th 2005, 10:28am

Author: spellcaster

Fixed size dialog

You should also keep in mind that not all users have the same system font and font size. So, if you want a fixed sized dialog that actually works, you'll have to calculate the size of the dialog on start-up.

Tuesday, July 12th 2005, 10:46pm

Author: spellcaster

Question about thumbnailing in Qt

I can see in your screenshot that the column of the dir-tree doesn't fill the complete width of the scroll area. There's a very simple way to fix that: derive a class from QDirModel, overload coulumnCount to return 1. MyDirModel.h: Source code 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 #ifndef MYDIRMODEL_H #define MYDIRMODEL_H #include <QDirModel> class MyDirModel : public QDirModel { Q_OBJECT public: MyDirModel( QObject * parent = 0 ); virtual int columnCount ( const QModelIndex & parent ) co...

Monday, July 11th 2005, 4:40pm

Author: spellcaster

inverseWorldMatrix question

Say you're writing a paint program. The user might want zoom in and paint in that zoomed view. If he has zoomed in 200% a click at pos 100,10 (pixel coords) would be at 50,5 (logical coords). Quoted Could you give an example of a situation where each would be used? If you want to support zooming, use it.

Monday, July 11th 2005, 3:36pm

Author: spellcaster

connect and multiple inheritance

Well, I'd say that your class B shouldn't be derived from A and widget, but simply from Widget and use a has-a instead of an is-a relationship. So class B has a "class A", not class B is a class A. But that's hard to tell without knowing what you're doing (or at least knowing the names of your classes).

Monday, July 11th 2005, 1:52pm

Author: spellcaster

Image browser

It's pretty fast on my (windows) box. The only thing that's slightly annoying 3.5" floppy access when the tree is created. I never noticed slowdowns while playing around with it.

Monday, July 11th 2005, 1:50pm

Author: spellcaster

Question about thumbnailing in Qt

Hm, ok. What about reading the images? Should this be done in on a per image or per directory basis? Right now I'd create an "ImageProvider" for a directory which would load the thumbs file (if existing) and update the list of images. The ListWidget derived class has a reference to the imageProvider and requests the preview for the files (passing the filename as key). Once the ImageProvider has loaded all images, he emits signal and the ListWidget redraws itself. Is this design ok?

Monday, July 11th 2005, 12:58pm

Author: spellcaster

RE: Question about thumbnailing in Qt

The listview with thumbnails seems to be a very common task. I've seen several messages of differnet user coding something like that. And I'm also coding a thumbnail list. Right now image loading is blocking and I'm not sure if I should start one thread per preview or one thread to load all previews. If somebody with a working implementation could post his code, that might save some time I'm currently considering to implement a "previewManager" that holds alist of files an loads the previews. It...

Monday, July 11th 2005, 12:40pm

Author: spellcaster

Image browser

I only tried resizeCOlumnToContents - and that worked like a charm