QTableView does not display database in release mode - c++

I have written an application in C++ using Qt 4.8 in Visual Studio 2010 and I try to make .exe with dlls. Everything seems to work just fine, but
when I run my program on another computer without any VS or Qt installed there, nothing gets displayed.
//class where I create database
DatabaseManager::DatabaseManager():
m_database(new QSqlDatabase(QSqlDatabase::addDatabase("QSQLITE")))
{
m_database->setDatabaseName("VirtualBank.db");
m_database->setHostName("localhost");
}
// Widget that has holds QTableView where that database gets displayed
CorporationWidget
{
//....
QTableView * m_wgt;
QSqlRelationalTableModel* m_model;
//....
}
void CorporationWidget::initializeModel()
{
setModel(new QSqlRelationalTableModel(this,*(getContext()->model->getDatabase())));
//....
}
Normal view: (on my computer)
Not normal view (on someone else's computer)
The dlls in folder:

Related

Clicking QSystemTrayIcon brings up an empty context menu on Mate desktop

I'd like to create a tray icon for my application for showing the main window on clicking on it after the former was minimized.
Here's the implementation:
TrayIcon.h:
class TrayIcon_t : public QSystemTrayIcon {
Q_OBJECT
public:
TrayIcon_t();
};
TrayIcon.cpp:
TrayIcon_t::TrayIcon_t() {
setIcon(QIcon(":/icons/tray.ico"));
}
Main.cpp (part only, there's no more code related to the tray):
TrayIcon_t *tray = new TrayIcon_t;
QObject::connect(tray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), &MainWindow, SLOT(show()));
tray->show();
While on LXDE it works just fine, on MATE desktop it mostly opens a small menu (I think) containing no items and doesn't emit the signal required by the main window to be shown. See this picture.
Do you think I've encountered a bug in Qt 5.7.0?
Turns out that this is a bug. Reported it and became accepted at:
https://bugreports.qt.io/browse/QTBUG-55717

Visual studio keeps running the application after returning 0x0 ( clean return ) C++

I'm a beginner when it comes to C++ programming, but for some reason, whenever I debug my code and run the application ( i`m using SDL2 ) and close the window in Visual Studio, the orange bar is still there.
In other words, even though the window closed and I triggered SDL_Quit() and other clean up code, the IDE keeps running the application.
I tried using the SUBSYSTEM SUBSTEM/:CONSOLE and the normal Windows mode but no joy.
What does it mean? Oh and just a heads-up, the main() function returns a normal 0x0. I havent build in any error/debug modes to return yet.
int main()
{
Debug::setVerbosity(VERBOSITY);
App * app = new App("C:/dev/out/resources/settings/debug_settings.json");
// initialize all the core systems and subsystems
if (app->start())
{
// the main game loop
app->run();
}
// clean up all the objects, settings etc
delete app;
return 0;
}

Differences in Windows and Linux. Using SFML and pointers

I just want to know more about cross-platfrom programming. I create game in SFML 2.1 and C++. And I have a problem. This code works under Linux, but it doesn't work under Windows (MinGW). There is no error, but nothing is drawn.
Shop::Shop(): shop_texts() {}
//...
void Shop::draw(App* app)
{
app->window.draw(shop_texts.getText("btn_playerskins"));
}
shop_texts returns an sf::Drawable object.
And then in App:
shop.draw(this);
shop_texts exists, because I can check e.g position or text (this object contains sf::Text field). What is difference?

How to gray out a menu item again in Qt

I am working with qt and have created a menu bar like "File" with some sub menu items "Open", "Save", "SaveAs", "Close", "Quit". I also created actions like "actionNew", "actionOpen", ... and so on. I used the same actions for the tool bar and disable the menu and tool bar items into the constructor with the "disableItems()" function, that works fine and the tool bar and menu items are gray out. If I clicked the sub menu item "New", the tool bar and menu items are enabled and not gray out, that also works fine, but if I clicked the sub menu item "Close" only the tool bar items gray out and the menu items are still enabled :(. How can i fix it? Hope you can help me and sorry for my bad English ;)
MainWindow::MainWindow(QWidget *parent)
:QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);
/* disable menu items and tool bar items */
disableItems();
}
void MainWindow::disableItems()
{
ui->actionSave->setEnabled(false);
ui->actionSaveAs->setEnabled(false);
ui->actionClose->setEnabled(false);
}
void MainWindow::enableItems()
{
ui->actionSave->setEnabled(true);
ui->actionSaveAs->setEnabled(true);
ui->actionClose->setEnabled(true);
}
void MainWindow::on_actionNew_triggered()
{
enableItems();
}
void MainWindow::on_actionClose_triggered()
{
disableItems();
}
I had the same problem.
I was puzzled because the code behaved differently from Linux 64 (where usually I develop), Windows (customer machine), Linux 32 (old development & backup machine). Then I realized the difference in version.
The only way to solve I found was to upgrade from default QtSDK that came with my Ubuntu distribution to the latest downloaded from here.
I suggest to check if the version you are using can be upgraded.
HTH
edit I noticed that they changed something more radical: after the upgrade the menubar is not more shared on 'top screen' but more traditionally inside the 'main window'. Probably the team overlooked a portability problem, that's reasonable considering the wide target they have.

GTK app: How do I create a working indicator with Qt/C++?

I've tried in 2 forums, but I had no luck so far.
So, I am using Qt IDE in order to build my application so as to participate to the Ubuntu Showdown contest. In my application, I've done the following:
void show_app(MainWindow *data)
{
//this works fine:
app_indicator_set_status(appindicator, APP_INDICATOR_STATUS_PASSIVE);
//this crashes the application:
data->show();
}
void MainWindow::make_indicator()
{
if(appindicator){
//appindicator has already been created
return;
}
appindicator = app_indicator_new("Format Junkie Indicator", "formatjunkie", APP_INDICATOR_CATEGORY_APPLICATION_STATUS);
GtkWidget* showapp_option;
GtkWidget* indicatormenu = gtk_menu_new();
GtkWidget* item = gtk_menu_item_new_with_label("Format Junkie main menu");
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), indicatormenu);
showapp_option = gtk_menu_item_new_with_label("Show App!");
g_signal_connect(showapp_option, "activate", G_CALLBACK(show_app), this);
gtk_menu_shell_append(GTK_MENU_SHELL(indicatormenu), showapp_option);
gtk_widget_show_all(indicatormenu);
app_indicator_set_status(appindicator, APP_INDICATOR_STATUS_ACTIVE);
app_indicator_set_attention_icon(appindicator, "dialog-warning");
app_indicator_set_menu(appindicator, GTK_MENU (indicatormenu));
}
So, basically I am trying to make a simple indicator entry, which, on click, it will hide the indicator and display the application. The indicator can be successfully hidden using the PASSIVE thingy over there, but, during the call data->show();, the application crashes.
Any help on what I am doing wrong would be appreciated! Also, please help me to correct this problem I'm facing (alternatively, I will migrate to the old and good tray icon (it works fine in Ubuntu 12.04, anyway) which I can handle very easily and efficiently)
The callback for the activate signal needs to have the following type:
void callback(GtkMenuItem *, gpointer)
So show_app should be defined like this
void show_app(GtkMenuItem *showapp_option, MainWindow *data)
That should solve your problem.