PDA

View Full Version : ShowMaximized dosen't run in my application. I don't know why.



druidamix
22nd September 2010, 13:30
Hello,

If I create a simple application with qt creator for a mobile with symbian s60. It dosen't maximize the widgets with showMaximized.


int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
#if defined(Q_WS_S60)
w.showMaximized();
#else
w.show();
#endif

return a.exec();
}


I don't understand why. Is there a bug?

Or maybe I have to run the function in another widget like the layout grid?

I'm a bit desperated.

Thank you.

nish
22nd September 2010, 13:34
just to make the test... use QMainWindow instead of your Mainwindow and see if the problem persists.

druidamix
22nd September 2010, 18:54
Well, the project use QMainWindow. I show you the code:

mainwindow.h

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
Q_OBJECT

public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();

private:
Ui::MainWindow *ui;

private slots:
void on_pushButton_clicked();
};

#endif // MAINWINDOW_H


main.cpp

#include <QtGui/QApplication>
#include "mainwindow.h"

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow2 w;

#if defined(Q_WS_S60)
w.showMaximized();
#else
w.show();
#endif

return a.exec();
}


mainwindow.cpp

#include "mainwindow.h"
#include "ui_mainwindow.h"

#include <QtGui>
#include "ListviewDelegate.h"


QStandardItemModel *model;
ListviewDelegate *listdelegate;


MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);



model = new QStandardItemModel();
listdelegate = new ListviewDelegate();


}

MainWindow::~MainWindow()
{
delete ui;



}

void MainWindow::on_pushButton_clicked()
{
ui->listView->setItemDelegate(listdelegate);
ui->listView->setModel(model);
QStandardItem *item = new QStandardItem();

item->setData("InBox",ListviewDelegate::headerTextRole);
item->setData("10 messages",ListviewDelegate::subHeaderTextrole);
item->setData("Hola que tal aixo es una prova jfhjklsd jfdlañj fklañjf lakñfj aklj fadklñfj aklfj aklj falñ",ListviewDelegate::rightTextRole);
model->appendRow(item);
}


Thank youuu!!

wysota
23rd September 2010, 00:44
You probably forgot to apply a layout to your main window.

nish
23rd September 2010, 07:25
I meant that dont use your derived class. Use directly a QMainWindow, just to check wether its a problem in your code.

druidamix
23rd September 2010, 13:09
Thank you!!!!!!!

Using that code works perfectly!!

I'll pay you a coffe. lol

This is the code:


int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QMainWindow wnd;
QWidget* window = new QWidget;
QVBoxLayout* layout = new QVBoxLayout(window);
QPushButton* optsButton = new QPushButton("Options");
QPushButton* exitButton = new QPushButton("Exit");
QCheckBox* chkBox = new QCheckBox("Checkbox");
QListView* listview = new QListView(window);
layout->addWidget(listview);
layout->addWidget(chkBox);
layout->addWidget(optsButton);
layout->addWidget(exitButton);

QObject::connect(exitButton, SIGNAL(clicked()), &app, SLOT(quit()));

wnd.setCentralWidget(window);

#if defined(Q_WS_S60)
wnd.showMaximized();
#else
wnd.show();
#endif
return app.exec();
}

nish
23rd September 2010, 13:49
now check your MainWindow class to see if you have used any of the size/hide/geometry functions that will cause the prob.