473,674 Members | 4,689 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

No taskbar button with qt

dzenanz
45 New Member
I had a small project based on Qt4, ITK and OpenSceneGraph. It's main function is shown below.
Expand|Select|Wrap|Line Numbers
  1. int main( int argc, char **argv )
  2. {
  3.     QApplication app(argc, argv);
  4.     MainWindow mainForm = new MainWindow();
  5.     mainForm.show();
  6.     return app.exec();    
  7. }
There was a problem, however. The window had no taskbar button. I spent quite some time figuring it out, and in the end it all came down to a very stupid difference: main form was instantiated with new operator.

The code that produces a normal window with taskbar:
Expand|Select|Wrap|Line Numbers
  1. int main( int argc, char **argv )
  2. {
  3.     QApplication app(argc, argv);
  4.     MainWindow mainForm;
  5.     mainForm.show();
  6.     return app.exec();    
  7. }
I am not sure weather this trick would work in other circumstances/platforms (I am using Windows XP/VisualStudio200 8).

I hope this will help someone with same/similar problem.

Keywords (to increase visibility in search engines):
Qt, osg, hide taskbar button, display taskbar button, opengl, main window
Mar 26 '09 #1
10 8239
weaknessforcats
9,208 Recognized Expert Moderator Expert
The C++ new operator returns rthe address of the MainWindow object and not the object itself.

You need code like trhat works with a MainWindow pointer:
Expand|Select|Wrap|Line Numbers
  1. int main( int argc, char **argv ) 
  2.     QApplication app(argc, argv); 
  3.     MainWindow* mainForm = new MainWindow; 
  4.     mainForm->show(); 
  5.     return app.exec();     
Mar 26 '09 #2
dzenanz
45 New Member
But the point is, everything worked (main window would show, you could alt-tab to it, etc), there was only no taskbar button.

And you are right, I can try that when I get to work. I did not notice it because compiler did not issue a warning/error about it!
Mar 26 '09 #3
weaknessforcats
9,208 Recognized Expert Moderator Expert
You will need to look at the code for MainWindow. You are calling the default constructor. There should be code there to create your task bar.

Expand|Select|Wrap|Line Numbers
  1. MainWindow* mainForm = new MainWindow;  
  2.  MainWindow mainForm; 
In each case above the MainWindow default constructor is called. In the first case the new operator returns the address of the object and in the second case the object is created as a local stack variable. That means in both cases you should get the same results.

The only difference is that using the new operator requires you to delete the pointer when you are done with it.
Mar 26 '09 #4
dzenanz
45 New Member
Incredible! You were right. When I use MainWindow *mainForm=new ... instead of MainWindow mainForm=new ... it also works normally. Makes me wonder even more why did compiler allow it, and why the whole thing worked (except the taskbar button, of course). MainWindow is a wrapper for something made in designer.
Expand|Select|Wrap|Line Numbers
  1. class MainWindow : public QMainWindow, public Ui::mainWindow
  2. {
  3.     Q_OBJECT
  4.  
  5. public:
  6.     using Ui::mainWindow::centralWidget;
  7.     MainWindow(QWidget *parent = 0);
  8.  
  9. protected:
  10.     void closeEvent(QCloseEvent *event);
  11.     void resizeEvent( QResizeEvent * event );
  12.  
  13. signals:
  14.     void fileOpened(std::string filename);
  15.  
  16. private slots:
  17.     void on_actionOpen_activated();
  18. };
Mar 27 '09 #5
weaknessforcats
9,208 Recognized Expert Moderator Expert
Your code does not compile using C++. That is:

Expand|Select|Wrap|Line Numbers
  1.    MainWindow mainForm = new MainWindow;  
is in error as far as C++ is concerned. It has to be:

Expand|Select|Wrap|Line Numbers
  1. MainWindow* mainForm = new MainWindow; 
Now I am not familiar with exactly what compiler you are using but whatever it is, it is not following C++ rules. Maybe you are using a C++-look-alike language that has different rules.
Mar 27 '09 #6
dzenanz
45 New Member
:D

I am using Microsoft Visual C++ 2008 IDE/compiler. Compiler not screaming about it must have something to do with Qt's additions.
Mar 27 '09 #7
weaknessforcats
9,208 Recognized Expert Moderator Expert
I am also using Microsoft Visual C++ 2008 IDE/compiler.

I have a C++ console application project and your code does not compile when you use the new operator assigning to an object rather than a pointer to an object.

Here is my error:
error C2440: 'initializing' : cannot convert from 'MainWindow *' to 'MainWindow'
generated from:

Expand|Select|Wrap|Line Numbers
  1. MainWindow mainForm = new MainWindow;  
whereas

Expand|Select|Wrap|Line Numbers
  1. MainWindow* mainForm = new MainWindow;  
compiles fine.
Mar 27 '09 #8
dzenanz
45 New Member
This program also uses OpenSceneGraph and InsightToolKit. If you have them on your system, maybe I can send you the entire project. Or I could rip those 2 out to make a minimal proof-of-concept example. I am in the beginning of starting a new project, so that should not be so hard. Maybe I can go tomorrow to workplace (University to be exact :D) to do it.

Of course, you have to be interested :D
Mar 27 '09 #9
weaknessforcats
9,208 Recognized Expert Moderator Expert
A proof-of-concept example would be interesting but more than that, step through your code using the debugger. Especially when using the C++ new operator assigning to a MainWindow object (the case that should not compile but does somehow on your machine).

That's all I would do myself.
Mar 28 '09 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1748
by: Wes | last post by:
I am writing a windows forms application in C#. When the application is has several instances running concurrently XP will normally group them (if the option is turned on). The grouped applications taskbar button is then labeled as (# Application Name) where # is the number of instances; however, in my application when the instances are grouped together the taskbar button is labeled as (#) and does not include the application name. How...
0
1070
by: Chris DiPierro | last post by:
If I do the following: App starts Dialog A Dialog A (in it's Load event) shows Dialog B modally Dialog B is set to show an icon in the taskbar If I run the application and don't perform any other action, all works normally. Dialog B appears on the task bar as expected. If, however, I run the application, and while the app is loading, I
6
6599
by: Mark | last post by:
Hi All, Does anyone know of a way that I can get a task bar button to flash if a form is open? I have created something like a messenger application within my database but there are a few people who have it open but do not use it exclusivley. If someone was to send them a message, it could be hours before they see it so if I could get the taskbar button to flash if the form opens, they can be alerted instantly. Many thanks,
1
2386
by: German Garbuglia | last post by:
Does anyone know how to implement FlashWindow or FlashWindowEx API Functions in C#? I need an example. I've no success implementing them. Thanks, German Garbuglia.
2
3126
by: hohrin | last post by:
Hopefully someone here will be able to point me in the right direction. In my C# application I have several forms which get a taskbar button when open. These buttons appear correctly with proper form name and application icon. however when the taskbar automatically groups the buttons together, the group button has no name, and the icon changes to the basic .exe icon. Is there a way to explicitly set the application group name and...
2
1906
by: Paul E Collins | last post by:
My application's main form has ShowInTaskbar set to false, because it is controlled by means of an icon in the notification area. When the icon is double-clicked, the application comes to the foreground (without any Taskbar button). While the application is thus visible, Alt+Tabbing between open windows shows the default application icon (white box with blue bar) instead of the icon used both for the application and for the main form....
8
1924
by: DarkBlue | last post by:
Hello In linux I use kmail as my email client under KDE, if a message comes in the Kontact button in the taskbar changes to blue. How can I have the same behaviour in a python app ? I have a python script which runs nicely under linux now every so often I want to be notified by some event, in this case that a record has been added to a database
10
2502
by: Mark Rae [MVP] | last post by:
Hi, This is really just a theoretical question for my own interest, and not for any nefarious purpose... :-) Say we have three applications running - Notepad, Wordpad and Excel - and each window is in its "normal" state i.e. not maximised, and not minimised to the taskbar. We click each of the three taskbar buttons in turn and, of course, the three
10
6716
by: mikeymike | last post by:
This is specifically for Windows 7, but any insight would be great. My app currently starts up and shows a form at the cursor position, but this is not feasible for what I would like as the user can quickly move the mouse after launching the application. So how would I got about getting the position of the task bar button and showing the window there?
0
8964
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8859
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8660
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8711
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7496
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5739
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4458
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2859
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2110
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.