I had a small project based on Qt4, ITK and OpenSceneGraph. It's main function is shown below. - int main( int argc, char **argv )
-
{
-
QApplication app(argc, argv);
-
MainWindow mainForm = new MainWindow();
-
mainForm.show();
-
return app.exec();
-
}
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: - int main( int argc, char **argv )
-
{
-
QApplication app(argc, argv);
-
MainWindow mainForm;
-
mainForm.show();
-
return app.exec();
-
}
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
10 8239
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: - int main( int argc, char **argv )
-
{
-
QApplication app(argc, argv);
-
MainWindow* mainForm = new MainWindow;
-
mainForm->show();
-
return app.exec();
-
}
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!
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. - MainWindow* mainForm = new MainWindow;
-
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.
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. - class MainWindow : public QMainWindow, public Ui::mainWindow
-
{
-
Q_OBJECT
-
-
public:
-
using Ui::mainWindow::centralWidget;
-
MainWindow(QWidget *parent = 0);
-
-
protected:
-
void closeEvent(QCloseEvent *event);
-
void resizeEvent( QResizeEvent * event );
-
-
signals:
-
void fileOpened(std::string filename);
-
-
private slots:
-
void on_actionOpen_activated();
-
};
Your code does not compile using C++. That is: - MainWindow mainForm = new MainWindow;
is in error as far as C++ is concerned. It has to be: - 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.
:D
I am using Microsoft Visual C++ 2008 IDE/compiler. Compiler not screaming about it must have something to do with Qt's additions.
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: - MainWindow mainForm = new MainWindow;
whereas - MainWindow* mainForm = new MainWindow;
compiles fine.
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
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.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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
|
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,
|
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.
|
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...
| |
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....
|
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
|
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
|
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?
|
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...
|
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...
| |
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,...
|
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...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |