Ошибка unicodeutf8 is not a member of qapplication

little_2

7 / 7 / 0

Регистрация: 15.11.2016

Сообщений: 36

1

06.05.2017, 19:08. Показов 3818. Ответов 9

Метки нет (Все метки)


Студворк — интернет-сервис помощи студентам

Здравствуйте! Помогите разрешить проблему!
Есть приложение для работы с базой данных.
В нём реализована форма, где все кнопки и различные action имеют русские подписи.
Проект успешно работал на Qt 4.8, но решился перейти на Qt 5 версии. При сборке выдаёт ошибку
«D:QT proekt4_05conectconectui_mainwindow.h:294: ошибка: ‘UnicodeUTF8’ is not a member of ‘QApplication’
MainWindow->setWindowTitle(QApplication::translate(«MainWindow», «MainWindow», 0, QApplication::UnicodeUTF8));

Ещё пример вывода ошибки:

C++ (Qt)
1
2
3
        action_6->setText(QApplication::translate("MainWindow", "320237320265321200320265320264320275320270320271 320272321200320260320271", 0, QApplication::UnicodeUTF8));
        action_7->setText(QApplication::translate("MainWindow", "320237320265321200320265320264320260321216321211320270320271 321200320260320264320270320276321206320265320275321202321200", 0, QApplication::UnicodeUTF8));
        action_8->setText(QApplication::translate("MainWindow", "320237320276320273320276321201321213 320277320276320273320265321202320260 320260320262320270320260321206320270320270", 0, QApplication::UnicodeUTF8));

В чем собственно проблема? Кодировка по умолчанию — системная. 1251 которая.



0



Programming

Эксперт

94731 / 64177 / 26122

Регистрация: 12.04.2006

Сообщений: 116,782

06.05.2017, 19:08

Ответы с готовыми решениями:

Неверная кодировка
Добрый вечер!
Хочу поздравить всех пользователей данного форума с Новым 2018-м Годом!
Пожелать им…

Неверная кодировка
здравствуйте!
Скажите пожалуйста выводит из БД текст крякозяблами , прописал…

Неверная кодировка в IE
Здравствуйте. Скачиваю архив с сервера. Именую его русскими символами. Но в IE выводит краказябры….

Неверная кодировка
Здравствуйте, подскажите, пожалуйста, как возможно решить, сложившуюся проблему.
Программа должна…

9

7535 / 6397 / 2917

Регистрация: 14.04.2014

Сообщений: 27,863

06.05.2017, 19:21

2

Это ты сам написал или сгенерировалось? Сделай очистку проекта и run qmake.



0



7 / 7 / 0

Регистрация: 15.11.2016

Сообщений: 36

06.05.2017, 19:26

 [ТС]

3

Это само сгенерировалось в ui_mainwidow.h
Очистка проекта не помогает.
Делаю «Очистить проект ‘connect'» -> «Запустить qmake»
Далее те же ошибки.



0



1069 / 651 / 229

Регистрация: 14.01.2016

Сообщений: 2,031

Записей в блоге: 9

07.05.2017, 07:22

4

Лучший ответ Сообщение было отмечено little_2 как решение

Решение

Цитата
Сообщение от little_2
Посмотреть сообщение

Очистка проекта не помогает.

Руками очисти, затем сделай qmake.

Добавлено через 2 минуты
https://wiki.qt.io/Transition_… deprecated



1



7 / 7 / 0

Регистрация: 15.11.2016

Сообщений: 36

07.05.2017, 09:56

 [ТС]

5

Действительно, почистил всё руками, ошибки исчезли. Теперь только осталось опять исправить кодировку, ибо она слетела с 1251. Спасибо за ответ!



0



7535 / 6397 / 2917

Регистрация: 14.04.2014

Сообщений: 27,863

07.05.2017, 10:10

6

Кодировка должна быть utf-8.



0



little_2

7 / 7 / 0

Регистрация: 15.11.2016

Сообщений: 36

07.05.2017, 10:35

 [ТС]

7

Должна быть. Поставил по умолчанию utf-8.
Но, например, у меня указано название окна

C++ (Qt)
1
setWindowTitle(tr("Задача №1"));//Наименование окна

Высвечиваются непонятные символы(см. картинку). Хотя другие русскоязычные элементы, которые были указаны в форме maindinwows.ui отображаются нормально.

PS:
Раньше использовал конструкцию вида:

C++ (Qt)
1
2
3
QTextCodec *utfcodec = QTextCodec::codecForName("CP-1251");
QTextCodec::setCodecForTr(utfcodec);
QTextCodec::setCodecForCStrings(utfcodec);

Но, читал, что в Qt5 версии такая вещь уже не нужна. Или я ошибаюсь?

Изображения

 



1



7535 / 6397 / 2917

Регистрация: 14.04.2014

Сообщений: 27,863

07.05.2017, 10:40

8

У тебя файлы h и cpp в utf-8?



2



7 / 7 / 0

Регистрация: 15.11.2016

Сообщений: 36

07.05.2017, 11:29

 [ТС]

9

Пересохранил блокнотиком все файлы в utf-8, действительно, некоторые были в другой кодировке. Спасибо!



1



51 / 149 / 33

Регистрация: 29.06.2019

Сообщений: 1,428

30.09.2020, 16:10

10

Цитата
Сообщение от little_2
Посмотреть сообщение

Действительно, почистил всё руками, ошибки исчезли.

в ui_widget.h тоже поудаляла все , QApplication::UnicodeUTF8 — запустился проект
спасибо за ветку



0



  • Home
  • Forum
  • Qt
  • Qt Programming
  • error: ‘UnicodeUTF8’ is not a member of ‘QApplication’

  1. 17th August 2013, 08:50


    #1

    Default error: ‘UnicodeUTF8’ is not a member of ‘QApplication’

    I am running a program I wrote in qt 4.7 with qt 5.0.1 I get the above error. Can I resolve this error?


  2. 17th August 2013, 12:47


    #2

    Default Re: error: ‘UnicodeUTF8’ is not a member of ‘QApplication’

    Refer this Deprecation

    Just in case the link is missing

    This enum type used to define the 8-bit encoding of character string arguments to translate(). This enum is now obsolete and UTF-8 will be used in all cases. So remove all instances of QCoreApplication::UnicodeUTF8.

    So just remove it, and don’t use it (inthe function parameters)

    When you know how to do it then you may do it wrong.
    When you don’t know how to do it then it is not that you may do it wrong but you may not do it right.


  3. The following user says thank you to Santosh Reddy for this useful post:

    atenakid (18th February 2014)


Similar Threads

  1. Replies: 2

    Last Post: 19th December 2011, 06:32

  2. Replies: 6

    Last Post: 6th March 2009, 21:16

  3. Replies: 3

    Last Post: 19th February 2008, 13:10

  4. Replies: 7

    Last Post: 5th February 2008, 11:26

  5. Replies: 4

    Last Post: 19th June 2006, 15:21

Bookmarks

Bookmarks


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
  • BB code is On
  • Smilies are On
  • [IMG] code is On
  • [VIDEO] code is On
  • HTML code is Off

Forum Rules

Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.

Перейти к контенту

  • Home
  • Forum
  • Qt
  • Qt Programming
  • error: ‘UnicodeUTF8’ is not a member of ‘QApplication’

  1. 17th August 2013, 09:50

    #1

    I am running a program I wrote in qt 4.7 with qt 5.0.1 I get the above error. Can I resolve this error?


  2. 17th August 2013, 13:47

    #2

    Default Re: error: ‘UnicodeUTF8’ is not a member of ‘QApplication’

    Refer this Deprecation

    Just in case the link is missing

    This enum type used to define the 8-bit encoding of character string arguments to translate(). This enum is now obsolete and UTF-8 will be used in all cases. So remove all instances of QCoreApplication::UnicodeUTF8.

    So just remove it, and don’t use it (inthe function parameters)

    When you know how to do it then you may do it wrong.
    When you don’t know how to do it then it is not that you may do it wrong but you may not do it right.


  3. The following user says thank you to Santosh Reddy for this useful post:

    atenakid (18th February 2014)


Similar Threads

  1. Replies: 2

    Last Post: 19th December 2011, 07:32

  2. Replies: 6

    Last Post: 6th March 2009, 22:16

  3. Replies: 3

    Last Post: 19th February 2008, 14:10

  4. Replies: 7

    Last Post: 5th February 2008, 12:26

  5. Replies: 4

    Last Post: 19th June 2006, 16:21

Bookmarks

Bookmarks


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
  • BB code is On
  • Smilies are On
  • [IMG] code is On
  • [VIDEO] code is On
  • HTML code is Off

Forum Rules

Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.

Hello guys,

I am new to the Klayout community. I hope I can learn as much as possible from you B)

I was trying to install Klayout on my Linux (Fedora 26) but I encountered some problems during the build process.

The error that I got during the building process is the following:

In file included from ../../../src/laybasic/laybasic/layBookmarkManagementForm.h:28:0,
from moc_layBookmarkManagementForm.cpp:9:
./ui_BookmarkManagementForm.h: In member function ‘void Ui_BookmarkManagementForm::retranslateUi(QDialog*)’:
./ui_BookmarkManagementForm.h:148:135: error: ‘UnicodeUTF8’ is not a member of ‘QApplication’
late(«BookmarkManagementForm», «Manage Bookmarks», 0, QApplication::UnicodeUTF8));
^~~
./ui_BookmarkManagementForm.h:149:129: error: ‘UnicodeUTF8’ is not a member of ‘QApplication’
gementForm», «Double-click to edit bookmark name», 0, QApplication::UnicodeUTF8));
^~~
./ui_BookmarkManagementForm.h:150:109: error: ‘UnicodeUTF8’ is not a member of ‘QApplication’
ion::translate(«BookmarkManagementForm», «Delete», 0, QApplication::UnicodeUTF8));
^~~
./ui_BookmarkManagementForm.h:151:101: error: ‘UnicodeUTF8’ is not a member of ‘QApplication’
ication::translate(«BookmarkManagementForm», «OK», 0, QApplication::UnicodeUTF8));
^~~
./ui_BookmarkManagementForm.h:152:109: error: ‘UnicodeUTF8’ is not a member of ‘QApplication’
ion::translate(«BookmarkManagementForm», «Cancel», 0, QApplication::UnicodeUTF8));
^~~
At global scope:
cc1plus: warning: unrecognized command line option ‘-Wno-reserved-user-defined-literal’
gmake[2]: *** [Makefile:12804: moc_layBookmarkManagementForm.o] Error 1
gmake[2]: Leaving directory ‘/home/kalosu/Documents/Nazca/klayout-0.26/build-release/laybasic/laybasic’
gmake[1]: *** [Makefile:46: sub-laybasic-make_first] Error 2
gmake[1]: Leaving directory ‘/home/kalosu/Documents/Nazca/klayout-0.26/build-release/laybasic’
gmake: *** [Makefile:276: sub-laybasic-make_first] Error 2

Any idea about what could I do to solve this?

Cheers,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <QMainWindow>
#include <QApplication>
#include <QLabel>
#include <QPushButton>
#include <QVBoxLayout>
#include <QWidget>
#include <QInputDialog>

class Form1 : public QMainWindow
{
    Q_OBJECT

public:
    explicit Form1(QWidget *parent = 0) : QMainWindow(parent) // Stuff to draw the window
    {
        centralWidget  = new QWidget(this);
        verticalLayout = new QVBoxLayout(centralWidget);
        Button1        = new QPushButton(centralWidget);
        label1         = new QLabel(centralWidget);

        Button1->setObjectName(QString::fromUtf8("Button1"));
        Button1->setText(QApplication::translate("Form1", "Push me", 0, QApplication::UnicodeUTF8));

        verticalLayout->addWidget(Button1);
        verticalLayout->addWidget(label1);

        this->setCentralWidget(centralWidget);

        QMetaObject::connectSlotsByName(this);
    }

private slots:
    void on_Button1_clicked()
    {
        Numberhidden = rand() % 100 + 1;
        Numberguess  = QInputDialog::getInteger(this, "", "Please enter your first guess", 50, 1, 100);

        while (Numberhidden != Numberguess && mycounter < 5)
        {
            if (Numberhidden > Numberguess)
                Numberguess = QInputDialog::getInteger(this, "", "Try a higher number, and enter your new guess", 0, 1, 100);
            else if (Numberhidden < Numberguess)
                Numberguess = QInputDialog::getInteger(this, "", "Try a lower number, and enter your new guess", 0, 1, 100);

            ++mycounter;
        }

        if (Numberhidden == Numberguess)
            label1->setText("You guessed it correct");
        else
            label1->setText("You have run out of opportunites");
    }

private:
    QWidget*     centralWidget;
    QVBoxLayout* verticalLayout;
    QPushButton* Button1;
    QLabel*      label1;

    int Numberhidden;
    int Numberguess;
    int mycounter = 0;
};

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    Form1 w;
    w.show();
    
    return a.exec();
}

При запуске скрипта выдается ошибка:

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc7 in position 0: 
    invalid continuation byte

Все работало на винде, но сейчас перешел на убунту и словил ошибку. IDE PyCharm.

#!/usr/bin/python
# -*- coding: utf8 -*-

import vk
import time

token = "8723b7"
session = vk.Session(access_token=token)
api = vk.api.API(session, v='5.80', land='ru')
adres2 = '//home//sergey//Рабочий стол//Alfa-Forex MetaTrader 
4//MQL4//Files//text.txt' #открытая группа

position2 = 0 #открытая группа

with open(adres2) as fh2:
    while True:
        fh2.seek(position2) #открытая группа

        data2 = fh2.read() #открытая группа

        position2 = fh2.tell() #открытая группа

        if data2:
            api.wall.post(owner_id='-11', message=data2)# открытая 
группа

        time.sleep(3)

ошибка:

/usr/bin/python3.6 /home/sergey/bin/Signal.py
Traceback (most recent call last):
 File "/home/sergey/bin/Signal.py", line 39, in <module>
   data2 = fh2.read() #открытая группа
 File "/usr/lib/python3.6/codecs.py", line 321, in decode
  (result, consumed) = self._buffer_decode(data, self.errors, final)
 UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc7 in position 
 0: invalid continuation byte

Объясните как это исправить?

QCoreApplication::UnicodeUTF8 is deprecated

This enum type used to define the 8-bit encoding of character string arguments to translate(). This enum is now obsolete and UTF-8 will be used in all cases. So remove all instances of QCoreApplication::UnicodeUTF8. For example:

Href_Gui->setWindowTitle(QApplication::translate("Href_Gui", "Url / www", 0, QApplication::UnicodeUTF8));
label->setText(QApplication::translate("Href_Gui", "Text:", 0, QApplication::UnicodeUTF8));
label_2->setText(QApplication::translate("Href_Gui", "Url:", 0, QApplication::UnicodeUTF8));
label_3->setText(QApplication::translate("Href_Gui", "Target / Name:", 0, QApplication::UnicodeUTF8));

to

Href_Gui->setWindowTitle(QApplication::translate("Href_Gui", "Url / www", 0));
label->setText(QApplication::translate("Href_Gui", "Text:", 0));
label_2->setText(QApplication::translate("Href_Gui", "Url:", 0));
label_3->setText(QApplication::translate("Href_Gui", "Target / Name:", 0));

This solved my problem

  • Ошибка unexpected character encountered while parsing value path line 0 position 0
  • Ошибка unhandled exception occurred see log for details dead air
  • Ошибка undefined на сайте налоговой
  • Ошибка unhandled exception occurred see log for details call of chernobyl
  • Ошибка undefined на сайте закупки