简体   繁体   中英

User system in Qt

I'm building an app that will run on our network for job tracking with two user levels, one for general users and one for administrators.

How are user systems usually implemented in Qt? For example, how are user state and user roles handled? Should I just include a C++ class and set these types of things as properties within that class, or are there established and well documented "best practices" for implementing user systems within Qt?

I also need to be able to share user state and role among various classes. For example, the menu class needs to know the user state & role to know what items to display.

Any help is appreciated!

What you are asking for doesn't make sense in terms of Qt on it's own. Qt is a framework for local client apps. The Qt application displays it's information to only 1 user at a time on one display / desktop at a time.

You framed the question in terms of a networked job tracking application. Lets assume this implies there is some sort of job tracking server. Likewise, let's assume you are writing a client for this server application in Qt. In this model you could let the Qt application login to the server using credentials provided by the user. Then it would be the server's job to tell you whether the user is who they claim to be and what role they have and to enforce any security restrictions.

Since you say you are familiar with web applications, lets draw an analogy. Qt is intended to provide you the tools to write the web browser only; you would still need to provide the the web server and web application to run within it. Thus

Qt application is to web browser as X is to web server. 

You have to provide "X", and that is where you implement the user system.

Of course Qt does provide basic support stuff like network sockets, but on it's own I don't think it's well suited to writing a server application.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM