5

My question is
Gui libraries like Qt and lets say for Windows operating systems how do they create all those graphical user interfaces(windows etc).

Does each operating system gives API's or something else to do so?If yes, then how operating systems draw all those windows and things.Do they (operating systems) "control" the screen and then draw each pixel one by one to achieve their goal the GUI?

I would like an answer that explains things at the lowest level possible but well i don't demand someone to write me everything that happens( even if i would like to) because i know many things are behind all these.So for this reason comments with links or suggested books which explain with details
on what is happening under the hood would be appreciated.

Lan Pac
  • 365
  • 4
  • 14
  • A fairly good question, but I'm afraid not really answerable. And yes, operating systems "control" pretty much everything when it comes to interacting with hardware. – Daniel Kamil Kozar Jun 08 '13 at 23:28

2 Answers2

1

Stackoverflow answers are not supposed to use links, comments can but not answers.

Each operating system and gui library is different, but, yes in some way, shape, or form they do actually draw every one of the pixels. It is often quite organized and many peformance solutions are used, optimized routines that can update a rectangle or some chunk of a screen, sometimes hardware gets involved (these days a lot of the time the hardware or basically gpus get involved the cpu asks the gpu to draw something then the gpus are busy placing all the pixels).

You would likely for example want to create some sort of font rendering function that is given the font, the string to display, the font size, and perhaps a clipping window to not go outside, or perhaps a function that with the font, size and string returns the number of pixels then you can adjust the string to fit and wrap (look around this web page for example, drag the window wider and narrower and watch what web text does).

Definitely some sort of image drawing routines with the ability to stretch or fit the drawing to the rectangle defined.

The fun stuff, games, etc has improved so rapidly over time that it is hard to go back to a simple line draw and area fill routine, etc. But also along with the technology the games brought simple things like web pages benefit...Again look around.

There are many open source programs and libraries you should just wander around the source code and see what you see.

old_timer
  • 69,149
  • 8
  • 89
  • 168
  • Thanks for your answer.As for the links in the answers, i had the wrong impression that it is ok because i had seen links in other questions answers. – Lan Pac Jun 22 '13 at 10:27
  • I have seen folks use links and have folks say not to use links, I dont know if it is a written rule but it makes sense as the answer/text on this site outlasts many of the links. the question and answer then becomes useless if the information is in the links and not on this site and the links are bad. The question should be here and not in links and the answer should be here and not in links for either to be useful to the readers. – old_timer Jun 22 '13 at 12:40
  • Link only answers are discouraged, you can use them as long as you explain and elaborate or even cite, this content taken from . Also not all links are permanent so it's important that your solution has content. – zardilior Jul 22 '21 at 13:38
1

The operating system provides libraries that interface with the monitor/display. In short, GUI libraries such as Qt interact with those libraries of the operating system and creates an easier bridge for you, the programmer to interact with the monitor. For instance, Qt might have a drawLine feature, which underneath is taking care of pixel arrangement related to drawing on the monitor/display for the operating system.

StevenTsooo
  • 498
  • 4
  • 13
  • Thanks.Your answer made me ensure some basic conclusions i made myself on how things could possibly work. – Lan Pac Jun 26 '13 at 09:11