Results 1 to 5 of 5

Thread: Software Layout (Multithreading, QWorkspace, Fileoperations)

  1. #1
    Join Date
    Mar 2007
    Location
    Bielefeld, Germany
    Posts
    9
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Software Layout (Multithreading, QWorkspace, Fileoperations)

    Hi all,
    not sure where to post this, so I'll put it in the Newbie-Section.

    I'm currently stuck at a general software layout without a clue about the best way to handle this:
    What I got is a QWorkspace inside the MainWindow and a QDockWidget displaying user names. If a user is clicked, a separate Widget is opened in the Workspace, displaying a loading-screen and an icon in front of the User shows the state 'Loading'. So far, so good...
    What I try to achieve is, if the loading screen is displayed, a corresponding logfile is opened and transferred into a QTableView with a SortProxyModel. The filesize can be up to 100 Mb, maybe more. After processing, the Icon shows the state 'Opened'. In theory, all users could be processed simultaneously. That is, where my problem arises.

    I tried to put processing in a Qthread, that has the Widget with the loading screen as its parent. If I close the loading-screen, end the thread with exit() and catch finished() to set the state back to 'Closed', the thread my be processed on and after reset sets the state to 'Opened' again. I don't like the idea of using terminate() because of locked mutexes and opened file-handles. Furthermore, a wait()-call blocks the whole GUI (and so the other opened userfiles).

    another idea would be, to put the displaying widget also in a thread, but then...is it possible to put the contained TableView to the workspace with addWindow?

    I'm a bit lost, how to best design these two processes. Maybe someone can give me a hint, how to start on this problem.

    Thanks in Advance,
    Daedalus

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Software Layout (Multithreading, QWorkspace, Fileoperations)

    I tried to put processing in a Qthread, that has the Widget with the loading screen as its parent.
    In general this is the way I would do it, spiliting the (possible) parallel work in a thread.
    Furthermore, a wait()-call blocks the whole GUI (and so the other opened userfiles).
    I am not sure I follow.
    From this it sounds, as if each thread you open will open a new dialog.
    This might make sence (though I am still not quite sure how) if your application is a netwrok server.
    But then the clients are the ones opening their own dilalog for each job, not the server.
    So, I am not sure what you said here.
    Furthermore, the whole idea to put the working thread in its own thread is also to separate it from the GUI thread.
    So if your GUI thread waits for the working thread, you don't need a separate thread, since its not parallel, but sequencial work.
    But I probably understood you wrong.
    Maybe on hand of my post you could clarify a bit more.

  3. #3
    Join Date
    Mar 2007
    Location
    Bielefeld, Germany
    Posts
    9
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Software Layout (Multithreading, QWorkspace, Fileoperations)

    To give a bit more background:

    Some software writes all clients to a csv file. Then creates a subdir with clients name and puts a logfile there (also csv-based). I'd like my application to be able to open a single TableView for each of these logfiles in the workspace.

    So for every selected client, a new analysis-widget will be opened and filled from the corresponding logfile .

    I hope, this explains the purpose somewhat better.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Software Layout (Multithreading, QWorkspace, Fileoperations)

    You could do it without threads at all... If you process files chunk by chunk, you can iterate all open files and do everything without blocking the GUI for too long.

  5. #5
    Join Date
    Mar 2007
    Location
    Bielefeld, Germany
    Posts
    9
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Software Layout (Multithreading, QWorkspace, Fileoperations)

    It turned out, that I need an importer-thread, because the files may be quite large( processing takes about one minute for a 75MB file, but time is not a vital factor here). But wysota's chunk-hint gave me the idea of simply checking an "abort"-Variable and taking all necessary measures, before calling exit(), resp. terminate() if it turns out to be needed, after every processed chunk of data.

    Seems to work, thanks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.