Re: Custom widgets in layout
You cannot show a layout only. A layout is something you apply to widgets to tell them how to place their contents.
What you need to do is
- create a window, e.g. QDialog
- set it's layout using QDialog::setLayout() to QVBoxLayout
- add your widgets to this layout (see QWidget::setLayout() for an example of how to do so)
You do not need to create a class that inherits QVBoxLayout.
For more information on layouts you should read the according section from the Qt documentation.
Re: Custom widgets in layout
Hi,
the main problem is in constructor of you class EncrypterBody
You actually forgot to show your gridLayout. Pass 'this' in constructor of QGridLayout object (line 1 here)
Code:
// UspořádánÃ* layoutu
layoutBody->addWidget(keyPublic, 0, 0, 1, 1);
layoutBody->addWidget(openFileName, 1, 0, 1, 1);
layoutBody->addWidget(text, 2, 0, 2, 1);
layoutBody->addLayout(layoutButtons, 2, 1);
layoutBody->setRowMinimumHeight(3, TEXT_H - (3 * BUTT_H + 8));
this solves your problem. So you don't have to do another class Layout (if you really dont want it for some reason). It could be enough to do it in main like this
Code:
#include <QApplication>
#include <QtGui>
#include "sifrator.h"
int main(int argc, char *argv[])
{
mainWindow.show();
EncrypterBody *partEncryption = new EncrypterBody(&mainWindow);
EncrypterBody *partDecryption = new EncrypterBody(&mainWindow);
QObject::connect(partEncryption,
SIGNAL(clickedTranslate
(QString)), partDecryption,
SLOT(setText
(QString)));
layout->addWidget(partEncryption);
layout->addWidget(partDecryption);
return sifrator.exec();
}
It was working for me.
Tak preji hodne zdaru
ahoj
Re: Custom widgets in layout
Ok, I tried what you said and It works... for other who might learn from mistakes of mine :)
This is the new code of main.cpp layout.h and layout.cpp exists no more :P
Code:
#include <QApplication>
#include <QVBoxLayout>
#include <QDialog>
//#include <QWidget>
#include "sifrator.h"
int main(int argc, char *argv[])
{
EncrypterBody *partEncryption = new EncrypterBody;
EncrypterBody *partDecryption = new EncrypterBody;
QObject::connect(partEncryption,
SIGNAL(clickedTranslate
(QString)), partDecryption,
SLOT(setText
(QString)));
layout->addWidget(partEncryption);
layout->addWidget(partDecryption);
window->setLayout(layout);
window->show();
return sifrator.exec();
}
Edit: Radek.z was faster, sorry I did not refreshed the page before posting :D
Thank you guys :)
Re: Custom widgets in layout
Hi,
what is an encryption, which you connecting in line 177 and 178 of your sifrator.cpp file. Is it a member?
(also decryption in line 206,207 in sifrator.cpp )
radek
Re: Custom widgets in layout
It is object of class Rsa... I am creating it on line 176 (the same applies for decryption object of Rsa class on line 205).
Code:
Rsa *encryption = new Rsa(0, true, n, e);
When I run it from console it does not say that those signals or slots do not exist. Weird
Re: Custom widgets in layout
Do I understand you correctly that your problem is that the progress bar is not updating? If you are doing calculations in the GUI thread that take some time, you should call QCoreApplication::processEvents() once in a while to give Qt a chance to update the GUI.
Re: Custom widgets in layout
Yeah, you understood it correctly, ty, will try that :)
Re: Custom widgets in layout
Hi,
did you figure out smthing?
I was looking at this.
in your fnc QString Rsa::toDigits(QString textNormal) I have tried to use
Code:
int rec
= QObject::receivers(SIGNAL(encryptbarMaximum
(int)));
qDebug()<<rec;
just after emiting this signal to see if it is connected to slots, and it show 0.
I think you should connect the Rsa object in different way. I tried it in constructor of your EncrypterBody class and it worked, but of course there is a problem with inicialiazing the parametrs of Rsa object, so this you shoudl figure out.
Radek
5 Attachment(s)
Re: Custom widgets in layout
Hi Radek.
With informations you provided I was able to do it :) I have to thank you again :)
Now I just have to figure out why mine power and modulo thing ((x pow y) mod z)) is returning wrong numbers. And also comment the code better as well as do some stylish editing of the code :)
Then I will surely came up with some other feature I would like to implement which wont work of course and then I will have kindly ask you to help me again :D
Btw if you have any advice of improving the code, let me know :)
Code is provided in attachment
Re: Custom widgets in layout
Hi,
so now the fun work starting, right? ;) .
I dont really feel like to be good in advice for improving code. I just saw that you use czech language for comments so it was easier for me then for smbdy else to help you.
So I wish you good luck and of course you welcome to ask me if some problem will come up. I will try to help you in case I will be able to.